Android Studio 从2.3迁移到3.0遇到的问题及解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/waley_yang/article/details/79022871

1.

之前的gradle版本:3.3-all

现在的gradle版本:4.1-all

原因是我用了 butterknife 配置问题:

解决办法:

 (1).删除:

  apply plugin: 'com.jakewharton.butterknife'

  和classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'

(2).增加:

build.gradle->android->defaultConfig里面增加

vectorDrawables.useSupportLibrary = true


2.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.

因为build.gradle中使用了自定义输出apk的代码:

    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                output.outputFile = new File(outputFile.parent, apkName)
            }
        }
    }

解决:  将自定义输出apk代码换成:

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

猜你喜欢

转载自blog.csdn.net/waley_yang/article/details/79022871