Android studio升级3.0.1问题合集

/

软硬件环境

  • Android studio 3.0.1
  • Windows 10

outputFile相关

错误信息

  1. 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.
  2. <a href="openFile:D:\longjing\proj\LivePlayer_branch_udp\app\build.gradle">Open File</a>

解决方法

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

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

butterknife相关

错误信息

  1. Error:Execution failed for task ':wigetlib:javaPreCompileDebug'.
  2. > 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.
  3. - butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
  4. 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.
  5. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

解决方法

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

  1. defaultConfig {
  2. applicationId "com.xugaoxiang.demo"
  3. minSdkVersion 15
  4. targetSdkVersion 25
  5. versionCode 2
  6. versionName "1.0.2"
  7. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  8. javaCompileOptions {
  9. annotationProcessorOptions {
  10. includeCompileClasspath = true
  11. }
  12. }
  13. }

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

参考资料

转载请注明作者和出处,并添加本页链接。
原文链接:http://xugaoxiang.com/post/111

给我留言