问题描述
我们最近升级到了 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.但他们没有提供有关原因的更多信息.
所以.
- 出了什么问题?还有更多信息吗?我在任何地方都找不到一个错误报告.
- 我该如何解决这个问题?这是否是说我不能建立一个依赖于其他本地 .aar 的 .aar?如果这个本地 aar 托管在 Maven Central 或其他远程仓库上会怎样?为什么会有不同?
我最近遇到了同样的问题,解决方法是从 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文件旁边. - 将新建的 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.
- What was the problem? Any more info? I can't find a single bug report anywhere.
- How exactly can I fix this? Is this saying that I can't build one .aar that depends on other local .aars? What if this local aar was instead hosted on Maven Central or another remote repo? Why would that make a difference?
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.
- Create a new directory and put the following content into the
build.gradlefile withing the new directory:
configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))
- Place the
aarinto this new directoy. Next to thebuild.gradlefile. - Add the new created Gradle project to the
settings.gradlefile:
include(":pathToTheCreatedDirectory")
- Include the project in your library where you want to use the
aar:
implementation project(":pathToTheCreatedDirectory", configuration = "default")
这篇关于构建 Android 库时出错:不支持直接本地 .aar 文件依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)