在Android Studio 3.X.X中,无法将本地.AAR文件添加到Android项目中(构建成功,但获取了运行时异常)
我尝试了以下方法(参考来源:https://stackoverflow.com/a/23326397/5685911,https://stackoverflow.com/a/24894387/5685911等),但没有一个对我有用:
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')
}
解决方法:需要将AAR模块导入的所有库都包含到应用程序级别gradle中。似乎未使用上述任何方法传播从AAR文件导入的内容。 但是,我认为这不是正确的解决方案。非常感谢您的任何帮助:)
答案 0 :(得分:0)
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')
}