Android 模块导入AAR时报错

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 :XXX project caused this error:

构建aar时不支持AAR文件依赖关系

以前版本的Android Gradle插件在这种情况下也会产生错误的AAR(尽管没有抛出这个错误)

解决方案:implementation 改为 compileOnly

Groovy 复制代码
libs下aar文件
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

把他改为
compileOnly fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

implementation: 依赖项在编译时和运行时都可见,并将包含在最终的构建输出中。这是最常用的依赖配置,用于指定项目在编译和运行时都需要的依赖项。
compileOnly: 依赖项仅在编译时可见,而在运行时不包含在最终的构建输出中。这意味着虽然在编译代码时可以使用这些依赖项,但它们不会被打包到最终的 JAR 或 APK 文件中。通常,compileOnly 用于指定在编译时需要,但在运行时由其他模块或系统提供的依赖项。

他仅仅只能消除警告

要在主项目导入

相关推荐
嵌入式-老费16 分钟前
esp32开发与应用(题外话之ADB和Android NDK开发)
android·adb
野生的码农20 分钟前
能工智人,40 大寿,尚能班否?
android·ai编程
事圆则缓26 分钟前
Android 串口通信:从 /dev/ttyS1到协议帧
android
java1234_小锋33 分钟前
【技术专题】CSS3 网页技术 - CSS3 基础样式
android·前端·css3
tongyiixiaohuang10 小时前
WMS已发货状态反写金蝶云星空:单策略实战教程
android
好的佩奇11 小时前
Dart 之类修饰符
android·flutter·dart
alexhilton12 小时前
用Konsist与Lint强制执行设计系统契约
android·kotlin·android jetpack
北京自在科技16 小时前
谷歌安卓 Gemini 迎来界面改版,Find Hub 接入 Gemini 支持物品记忆查找
android·安卓
YB137518 小时前
Jetpack Compose 动画Modifier.animateItem()
android
2401_8858850419 小时前
巴林语音通知接口如何对接?系统告警语音API接入教程
android·前端·网络·python·语音识别