当前位置:   article > 正文

搞定Direct local .aar file dependencies are not supported when building an AAR.把AAR以module方式加入

direct local .aar file dependencies are not supported when building an aar.

用新AS打开老项目是遇到一个这样的报错,新建一个项目来测试一下

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 :aartest project caused this error: 

第一步 新建module-》build.gradle 文件改成这样(新建的module多余的东西删掉保留build.gradle)

将aar文件移到和图里一样的地方,然后build.gradle文件修改成如下代码(名字自己换,原来的arr删除掉,移到这里)

  1. configurations.maybeCreate("default")
  2. artifacts.add("default", file('alipaySdk.aar'))

在你要引用aar的module里

  api project(path: ":arrDir")

我这里app还需要依赖arrtest模块 ,arrtest里用api 这样app也可以用alipaySdk.aar ,app依赖如下

    implementation project(path: ':aartest')

最后别忘了在 setting.gradle加入include ':arrDir'  (一般会new module的时候自动添加)

(我是Gradle7.0版本)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/607991
推荐阅读
相关标签
  

闽ICP备14008679号