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 用于指定在编译时需要,但在运行时由其他模块或系统提供的依赖项。

他仅仅只能消除警告

要在主项目导入

相关推荐
墨天梦1 小时前
B16_Material主题与可访问交互
android·kotlin·交互
弯_弯1 小时前
企业知识库 RAG 落地:从 Demo 到生产,四条工程链路与参数级自查
android·java·javascript
晚风叙码3 小时前
MySQL 表的约束详解:从空属性到外键
android·数据库·mysql·adb
alexhilton13 小时前
模块化Jetpack Compose架构
android·kotlin·android jetpack
厮年断弦15 小时前
AI 辅助开发实录:一周做完一个 Android 本地音乐播放器,这些坑替你踩了
android
hai_android15 小时前
InputStage 责任链核心执行流程
android·android studio·android jetpack
mmsx18 小时前
Android 测绘计算工程化:七四参数、高程拟合与单位系统
android·kotlin
我是场20 小时前
我的NPI项目之-Touch的EE特性
android·arm开发
天空之城--20 小时前
Android一周动态:AI编程、Compose与车载生态新信号
android·flutter
恋猫de小郭21 小时前
Dart 4.0 要彻底移除 dart:mirrors,Augmentations 应该要来了
android·前端·flutter