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

他仅仅只能消除警告

要在主项目导入

相关推荐
诸神黄昏EX几秒前
Android Google KEY
android
一起搞IT吧7 分钟前
Android性能系列专题理论之十一:block IO问题分析思路
android·嵌入式硬件·智能手机·性能优化
小妖6661 小时前
怎么用 tauri 创建编译 android 应用程序
android·tauri
鸟儿不吃草2 小时前
安卓实现左右布局聊天界面
android·开发语言·python
xxjj998a3 小时前
Laravel 1.x:PHP框架的原始魅力
android·php·laravel
formula100004 小时前
在iOS/安卓上远程连接任何 Agent!Claude、Codex、Copilot、Gemini、OpenCode 等
android·copilot
该用户可能存在4 小时前
Blbl-android 更新至 v0.1.24,体验更流畅、更稳定
android·哔哩哔哩·电视app·androidtv·bbll·blbl·bilibilitv
lKWO OMET4 小时前
mysql之字符串函数
android·数据库·mysql
liang_jy15 小时前
Android SparseArray
android·源码
liang_jy15 小时前
Activity 启动流程扩展篇(一)—— startActivityInner 任务决策全解析
android·源码