AS升级3.0,gradle plugin 升级到3.0.0遇到的问题
1.Error:Could not get unknown property 'apkVariantData' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
答:这个是因为Tinker中用到了apkVariantData属性,我们可以将tiner的gradle去除掉。上面是发现tinker有问题,另外发现GrowingIO也有这个问题,如果用的是gradle plugin3.0.0的话也需要去掉,如果还有童鞋有补充的,欢迎留言。
2.如果你的项目用到了,类似releaseCompile或者debugCompile的情况,根据配置来进行编译,会报如下的错误
Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :library. Error:Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :library.
可以用下面的语句来进行替换
dependencies { implementation project(':library') // You can, however, keep using variant-specific configurations when // targeting external dependencies. The following line adds 'app-magic' // as a dependency to only the "debug" version of your module. debugImplementation 'com.example.android:app-magic:12.3' }
3.Could not resolve com.android.support:multidex:1.0.2."
答:在项目录根目录下面的build.gradle文件增加:
buildscript { repositories { ...... if (GRADLE_PLUGIN_VERSION_NEWER == "true") google() } } allprojects { repositories { maven { url 'https://maven.google.com' } } }
4.找不到outputFile属性
Error:(37, 1) A problem occurred configuring project ':app'. > Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=release, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
答:each改成all,而且那个fileName就是文件名,不需要路径,因为在3.0的gradle插件,output.OutputFile是只读属性,所以修改apk打包的文件名,需要用outputFileName.
5.目前我的方案是在gradle.properties中增加GRADLE_PLUGIN_VERSION_NEWER=true的配置属性,gradle插件的是否是3.0.0版本,是为true,不是为false,其他地方在配置的时候增加这个判断,如果是true,就用最新的配置,false就用老的配置。
如果大家有在升级3.0的过程,有遇到别的问题,欢迎留言交流,谢谢。
相关推荐
CaesarHome 2020-11-09
chenkai00 2020-07-26
CaptainCTR 2020-07-09
afa0 2020-06-23
StephenWong 2020-06-18
chenkai00 2020-06-13
Lucianoesu 2020-06-08
tysforwork 2020-06-05
貌似掉线 2020-05-30
tysforwork 2020-05-27
CaptainCTR 2020-05-07
CaptainCTR 2020-05-04
貌似掉线 2020-05-03
CaptainCTR 2020-04-29
貌似掉线 2020-04-29
CaptainCTR 2020-04-23