Android-studio-3.0升级问题合集

原文出处: http://www.xugaoxiang.com/post/111

软硬件环境

  • Android studio 3.0.1
  • Windows 10

outputFile相关

错误信息

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

android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${variant.name}-${variant.versionName}.apk"
        }
    }

butterknife相关

错误信息

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

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已经不适用了。

参考资料

猜你喜欢

转载自blog.csdn.net/djstavav/article/details/79161127