You need to enable JavaScript to run this app.
导航
Gradle 高版本依赖本地aar打包问题解决方案
最近更新时间:2025.03.18 12:29:36首次发布时间:2025.03.18 12:29:36
我的收藏
有用
有用
无用
无用
背景

在使用Gradle高版本依赖本地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 :library_core project caused this error: X:\xxxxxxxx\library_core\libs\effectAAR-release.aar

解决方案

解决方案:将library_core模块本地直接依赖aar的方式修改为本地仓依赖的方式

具体分为下面3步:

  1. 将effectAAR-release.aar SDK文件移动到上一级目录
  • 移动前:

Image

  • 移动后:

Image

  1. 删除library_core目录中多余文件
  • 删除前:

Image

  • 删除后:

Image

  1. 修改library_core模块下build.gradle中的内容
  • 将原有build.gradle文件中的内容全部删除
  • 添加下方内容到build.gradle文件中
configurations.maybeCreate("default")
artifacts {
    add("default", file("effectAAR-release.aar"))
} 
  • 修改后的build.gradle文件

build.gradle