问题.
Gradle依赖管理如下:
目标.
那么这是我试图在我的设备上调试的项目(Router Keygen)的源代码.不幸的是,当我运行它时,我收到以下错误:
Error:Execution failed for task ':routerKeygen:ndkBuild'.
> Process 'command 'C:\Users\Dev\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd'' finished with non-zero exit value 2
Run Code Online (Sandbox Code Playgroud)
显示很多帖子.我无法理解是否正确安装了ndk(在我的计算机上).我只是想知道是否有人尝试过路由器keygen并且像我一样有同样的错误.如果没有,我应该尝试将ndk移动到其他地方吗?
我对 Android Studio 的经验不是很丰富,我尝试了无数方法来解决这个问题,但都没有成功。
目标:将.aar文件作为库导入到 Android Studio 应用中。
问题:



忽略问号,我接下来做了3件事,遵循一个成功的指南:



完成所有这些步骤后,我尝试同步 gradle,但它仍然无法识别 .aar。这些是错误:

我尝试将 .aar 文件放入 libs 文件夹,并将 build.gradle(Project:MyApplication) 中的此函数更改为:

但它解决不了任何问题。由于指南,我知道我正在尝试做的事情是可能的,但我不知道我错过了什么。该指南是供参考的:
(顺便说一下,我这样做是为了能够从 Android 活动启动示例 Unity 应用程序。在这种情况下,Unity 应用程序是一个旋转的立方体。)
非常感谢您在这件事上的时间和帮助。
我曾经能够将库 aar 文件作为模块导入,并且它们一直运行良好。我不知道如何使用最新版本的 Android Studio Arctic Fox 来做到这一点。有人可以提供一些建议吗?
我可以按照官方说明通过在 build.gradle 中添加以下内容来添加 aar 作为依赖项:
implementation files('libs/myLibrary-release.aar')
Run Code Online (Sandbox Code Playgroud)
不幸的是,这将需要依赖应用程序(即在其 build.gradle 中使用上述行来使用库的应用程序)了解 myLibrary 使用哪些外部库并添加所有依赖项。例如,如果 myLibrary 有 30 个依赖项,例如“implementation 'joda-time:joda-time:2.10.5'”,则每个依赖应用程序都必须具有这 30 个依赖项。如果 myLibrary 更新了新的依赖项,则所有依赖应用程序也需要添加它。最糟糕的是,应用程序可以在没有这些依赖项的情况下正常构建和启动,但在需要缺少依赖项时会在运行时崩溃。
我遇到Android Studio识别本地导入的@aar库中的类的问题.
所以...我已经创建了一个库并导出了一个aar文件.在android工作室里面,我选择了Import Module他们Import .JAR or .AAR Package.
该项目编译并使用aar文件中的类,但Android工作室无法找到类或提供任何自动完成所有.
以下是一些截图:

使用相同方式导入的其他@aar库也会出现同样的问题:

有什么建议?
编辑:
的build.gradle:
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':UpPlatformSdk')
compile project(':simpleorm')
... // more libraries here
}
Run Code Online (Sandbox Code Playgroud)
settings.gradle:
include ':app', ':UpPlatformSdk', ':wear', ':simpleorm'
Run Code Online (Sandbox Code Playgroud) 我正在编写一个插件来使用filepicker的原生android SDK https://github.com/Ink/filepicker-android.
在maven central上,它们只提供.aar文件(http://search.maven.org/#artifactdetails%7Cio.filepicker%7Cfilepicker-android%7C3.8.13%7Caar)而不是.jar.
如果我在config.xml中添加此行
<source-file src="src/android/filepicker-android-3.8.13.aar" target-dir="libs/" />
该文件是在libs中复制但在构建过程中未包含在类路径中cordova build,因此构建失败.
包含带有aar文件的第三方库的最佳解决方案是什么?
谢谢您的帮助
在我的Android Studio项目中,我有两个子项目/模块:Android应用程序(App1)和Android库项目(LibraryProject1).App1取决于LibraryProject1.到现在为止还挺好.
但是,LibraryProject1反过来,需要导入AAR库才能正常工作.
所以,我的配置如下:
App1包括LibraryProject1
LibraryProject1包括dependency.aar
现在,要包含dependecy.aar我使用此处详述的方法:
如何使用新的Gradle Android Build System手动包含外部aar包
所以基本上在我的build.gradle面前LibraryProject1我有:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile (name:'dependency', ext:'aar') //my AAR dependency
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
Run Code Online (Sandbox Code Playgroud)
显然,我将dependency.aar文件放在LibraryProject1的libs目录中
但是,这不起作用.似乎添加的存储库LibraryProject1完全被忽略,并且本地"libs"文件夹不包含在存储库中,导致编译失败.
如果我从添加该存储库中App1的build.gradle它的工作原理,但我不想这样做,这是LibraryProject1需要的AAR文件,而不是App1.
我怎样才能做到这一点??
Java Jarbuild.gradle模块:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'junit:junit:4.12'
// rx
compile "io.reactivex.rxjava2:rxjava:2.0.4"
compile "io.reactivex.rxjava2:rxandroid:2.0.1"
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
Run Code Online (Sandbox Code Playgroud)
这个 Jar 应该是一个库,用作单元测试 android 项目的实用程序库:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// test
testCompile 'junit:junit:4.12'
testCompile project(':test-utils')
// ... other non-test dependencies here (including rx)
}
Run Code Online (Sandbox Code Playgroud)
这包括:
testCompile project(':test-utils')
Run Code Online (Sandbox Code Playgroud)
失败:
错误:模块 'my-android-app:test-utils:unspecified' 依赖于一个或多个 Android 库,但它是一个 jar
这是因为RxAndroid是一个 Android .aar 库。 …
更新至'com.android.tools.build:gradle:3.5.0'
找到构建错误:
任务':truecp_player:mergeDebugJavaResource'的执行失败。执行com.android.build.gradle.internal.tasks.Workers $ ActionFacade时发生故障,使用操作系统独立路径“ classes.jar”找到了多个文件
ps:'com.android.tools.build:gradle:3.4.2'工作正常。
更新:如果库模块具有某些本地.aar文件依赖性,将发生错误!
库模块:
apply plugin: 'com.android.library'
def androidConfig = rootProject.extensions.getByName("ext").android
android {
compileSdkVersion androidConfig.compileSdkVersion
buildToolsVersion androidConfig.buildToolsVersion
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api fileTree(include: ['*.jar', "*.aar"], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Run Code Online (Sandbox Code Playgroud)