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

他仅仅只能消除警告

要在主项目导入

相关推荐
他们叫我技术总监28 分钟前
Python 列表、集合、字典核心区别
android·java·python
2401_882351524 小时前
Flutter for OpenHarmony 商城App实战 - 地址编辑实现
android·java·flutter
42nf5 小时前
Android 根据platform.pk8和platform.x509.pem生成.jks文件
android·.pk8和.pem生成.jks
摘星编程6 小时前
React Native for OpenHarmony 实战:DisplayInfo 显示信息详解
android·react native·react.js
_李小白6 小时前
【Android 美颜相机】第六天:GPUImageView解析
android·数码相机
Mr_sun.7 小时前
Day04——权限认证-基础
android·服务器·数据库
北辰当尹9 小时前
第27天 安全开发-PHP应用&TP框架&路由访问&对象操作&内置过滤绕过&核心漏洞
android·安全·php
yueqc19 小时前
Android 线程梳理
android·线程
顾林海10 小时前
Android登录模块设计:别让“大门”变成“破篱笆”
android·经验分享·面试·架构·移动端
嵌入式-老费10 小时前
Android开发(总结)
android