徐高翔的个人网站

Android-studio-3.0升级问题合集

2016-10-15

软硬件环境

  • Android studio 3.0.1
  • Windows 10

outputFile相关

错误信息

1
2
Error:(37, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
<a href="openFile:D:\longjing\proj\LivePlayer_branch_udp\app\build.gradle">Open File</a>

解决方法

修改你app模块(不是android工程下的)下的build.gradle

1
2
3
4
5
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}

butterknife相关

错误信息

1
2
3
4
5
Error:Execution failed for task ':wigetlib:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

解决方法

修改app模块下的build.gradle,在defaultConfig标签下增加javaCompileOptions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
defaultConfig {
applicationId "com.xugaoxiang.demo"
minSdkVersion 15
targetSdkVersion 25
versionCode 2
versionName "1.0.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}

}

android studio 3.0.1版本增加了第三方库更新的提示,butterknife已经升级到了8.6.0,除了上述解决方法,你还可以通过更新库的方式来解决,只不过需要去修改代码了,很多API已经不适用了。

参考资料

推荐文章(由hexo文章推荐插件驱动)

使用支付宝打赏
使用微信打赏

请博主喝咖啡!