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

他仅仅只能消除警告

要在主项目导入

相关推荐
Xzaveir1 小时前
别把所有“认证”都塞进 AuthService:实名、一键登录与号码身份的领域拆分
android·人工智能
BerrySen1782 小时前
KMP全栈开发:从Android到AI Agent的技术演进与实践
android·人工智能
AFinalStone3 小时前
Android 7系统休眠唤醒(一)电源管理架构全景图
android·powermanager·电源管理
YM52e3 小时前
鸿蒙Flutter Center居中组件:Align对齐详解
android·学习·flutter·华为·harmonyos·鸿蒙
时间的拾荒人4 小时前
MySQL 视图详解
android·数据库·mysql
祉猷并茂,雯华若锦5 小时前
Appium 3.x安卓按键与通知栏操作全指南
android·appium
码农coding5 小时前
android 12 SurfaceFlinger开机启动分析
android
hunterandroid6 小时前
Paging 3 RemoteMediator 实战:构建离线优先的分页列表
android·前端
码农coding6 小时前
android12 开机启动PMS
android
Days20506 小时前
GPT-Image-2 国风美学人设生成提示词分享
android·gpt