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

libs下aar文件
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值