友盟多渠道打包配置报错Cannot set the value of read-only property 'outputFile'

更新Android Studio 3.0之后,出现Cannot set the value of read-only property ‘outputFile’报错,也就是用来打包后重命名的gradle出现了问题

旧版本

AS 2.3时用的代码:

applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('.apk')) {
                def fileName = "release_${variant.productFlavors[0].name}_v${defaultConfig.versionName}.apk"
                output.outputFile = new File(outputFile.parent, fileName)
            }
        }
    }

修改之后:

android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "release_${variant.productFlavors[0].name}_v${variant.versionName}.apk"
        }
    }

你可能感兴趣的:(Android,友盟,多渠道打包,gradle)