随着手机系统版本越来越高,现在市面上安卓手机系统版本基本都在12、13了。目前应用市场对上架的应用targetSDK版本也有了最低限制,要求不低于30 各个版本的适配都少不了,不过现在用AndroidStudio 工具创建的新项目,默认targetSDK 和 compileSdkVersion 基本都在33 和 34 了,都想着用新的自然也是最好的了,不过我们很多项目一般体量都不算小,都会有多module互相依赖情况,也有引用三方aar的包等,最近我发现当 targetSDK 到了33之后,在项目多module时,在公共module引用aar时,出现了代码都没变动时,debug运行没有问题,release时就报错了:
Caused by: java.lang.RuntimeException: 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 :lib_base project caused this error:
然后就是各个aar包引入报错,任你随便改,都找不到好的处理办法。 我是搞了大半天,也没处理好,各种搜索。 最后处理办法是,直接在build.gradle 中加一行代码即可,
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
查询发现,它的大概意思是:在编译时,检测依赖之间可能会存在资源缺失的情况,这个写会有发生问题的可能。为了避免直接错误提示,逼着让你在哪里用aar就在那里引入。真的烦人啊,但是debug时,它是不检测的。以此记录,后续有问题好查看