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

他仅仅只能消除警告

要在主项目导入

相关推荐
菜就多学34 分钟前
SurfaceControlViewHost 实现跨进程UI渲染
android·设计
2501_915106321 小时前
iOS App 测试工具全景分析,构建从开发调试到线上监控的多阶段工具链体系
android·测试工具·ios·小程序·uni-app·iphone·webview
小羊在奋斗2 小时前
MySQL表的约束:从基础到核心(附场景+案例)
android·数据库·mysql
e***19352 小时前
MySQL-mysql zip安装包配置教程
android·mysql·adb
方白羽2 小时前
Kotlin遇上Java 静态方法
android·java·kotlin
q***06473 小时前
SpringSecurity相关jar包的介绍
android·前端·后端
7***31884 小时前
若依微服务中配置 MySQL + DM 多数据源
android·mysql·微服务
我是好小孩4 小时前
【Android】常见的架构模式:MVC, MCP, MVVM
android·架构·mvc
Digitally4 小时前
如何通过蓝牙将联系人从 iPhone 传输到 Android
android·ios·iphone
embrace996 小时前
【C语言学习】结构体详解
android·c语言·开发语言·数据结构·学习·算法·青少年编程