Akk*_*kki 2 android gradle build.gradle android-gradle-plugin aar
使用 Android Studio 3.XX,将本地 .AAR 文件添加到 Android 项目不起作用(构建成功但运行时出现异常)
我尝试下面的方法(摘自参考来源:/sf/answers/1632847821/,/sf/answers/1742607121/等),但没有为我工作:
1. Import the local aar file:
(I) File>New>New Module>Import the .AAR Package [On "Finish" click the .AAR gets included automatically into settings.gradle file as below:
include ':app', ':myAAR'
(II) Add AAR module dependency in app level build.grdle file as below:
implementation project(":myAAR")
2. Using flatDir method:
(I) keep aar file in libs folder
(II) Add flatDir{dirs 'libs'} into the project level build.gradle file as below:
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
(III) Add AAR dependency in app level build.gradle file as below:
dependencies {
implementation(name:'myAAR', ext: 'aar')
}
Run Code Online (Sandbox Code Playgroud)
解决方法:需要将 AAR 模块导入的所有库都包含到应用程序级别的 gradle 中。似乎使用上述任何方法都不会传播来自 AAR 文件的导入。但是,我认为这不是正确的解决方案。在这里非常感谢任何帮助:)
File name: C://release.aa r
Subproject name: my_subproject_name
app/build.gradle文件:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':my_subproject_name')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8666 次 |
| 最近记录: |