小编pk4*_*393的帖子

在gradle中更改apk文件名失败,使用gradle:3.0.0-alpha4

我想在我的项目中使用android构建工具"com.android.tools.build:gradle:3.0.0-alpha4".在我的构建脚本中,我重命名输出apk,它在过去运行良好但似乎不再受支持.

android {

   productFlavors {
        flavorUnsigned {
            applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    output.outputFile = new File(
                            output.outputFile.parent,
                            output.outputFile.name.replace("app-flavorUnsigned-release-unsigned.apk", "DemoApp-${variant.versionName}($variant.versionCode).apk"))
                    def mappingFile = "${rootDir}/app/build/outputs/mapping/${getCurrentFlavor()}/release/mapping.txt"
                    if (variant.getBuildType().isMinifyEnabled()) {
                        variant.assemble.doLast {
                            copy {
                                from "${mappingFile}"
                                into "${rootDir}/app/build/outputs/apk"
                            }
                        }
                    }
                }
            }
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

但是现在我在构建项目时遇到了这个错误

Error:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=flavorUnsignedDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin

6
推荐指数
1
解决办法
3569
查看次数

找不到support-fragment.jar(com.android.support:support-fragment:27.0.2)

我克隆了我的项目,并使用Android工作室打开,但是构建失败并出现以下错误,同样的项目对其他人工作正常.

android android-gradle-plugin

2
推荐指数
1
解决办法
2031
查看次数

标签 统计

android ×2

android-gradle-plugin ×2