赞
踩
用新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删除掉,移到这里)
- configurations.maybeCreate("default")
- 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版本)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。