我们最近升级到了 Android Gradle 插件 4.0.0-beta03.我们现在在构建我们的库模块之一时看到此错误
<上一页>$ ./gradlew library_module: 组装任务 ':library_module:bundleDebugAar' 执行失败.> 构建 AAR 时不支持直接本地 .aar 文件依赖项.生成的 AAR 将被破坏,因为来自任何本地 .aar 的类和 Android 资源文件依赖项不会打包在生成的 AAR 中.以前版本的 Android在这种情况下,Gradle 插件也会产生损坏的 AAR(尽管没有抛出此错误).这以下 :library_module 项目的直接本地 .aar 文件依赖项导致此错误:______.aar我可以看到这是几个月前添加到 AGP.但他们没有提供有关原因的更多信息.
所以.
我最近遇到了同样的问题,解决方法是从 libs/
中删除库并使用 File 导入它 ->新 ->新模块 ->导入.JAR/.AAR Package
,然后在库模块build.gradle
文件中引用:
依赖项{实施项目(:imported_aar_module")}
如果您使用的是较新的 Android Studio 版本 (4.0.0+),则此选项不可用.相反,您必须手动完成.
build.gradle
文件中:configurations.maybeCreate("default")artifacts.add("default", file('[nameOfTheAar].aar'))
aar
放入这个新目录中.build.gradle
文件旁边.settings.gradle
文件中:include(":pathToTheCreatedDirectory")
aar
的库中:实施项目(":pathToTheCreatedDirectory", configuration = "default")
We recently upgraded to Android Gradle Plugin 4.0.0-beta03. We are now seeing this error when building one of our library modules
$ ./gradlew library_module:assemble Execution failed for task ':library_module:bundleDebugAar'. > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :library_module project caused this error: ______.aar
I can see this was added to AGP a few months ago. But they provide no further info on why.
So.
I recently encountered the same issue, the fix was to remove the library from libs/
and import it using File -> New -> New Module -> Import .JAR/.AAR Package
, then referencing it in the library module build.gradle
file:
dependencies {
implementation project(":imported_aar_module")
}
If you are on a newer Android Studio version (4.0.0+), this option is not available. Instead you have to do it manually.
build.gradle
file withing the new directory:
configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))
aar
into this new directoy. Next to the build.gradle
file.settings.gradle
file:
include(":pathToTheCreatedDirectory")
aar
:
implementation project(":pathToTheCreatedDirectory", configuration = "default")
这篇关于构建 Android 库时出错:不支持直接本地 .aar 文件依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!