Fix Gradle sync failed: Cannot set the value of read-only property 'outputFile' for.....

1186 단어 TipsAndroid
안드로이드 스튜디오를 3.0으로 업그레이드합니다.X 버전 중 동기화 오류가 발생했습니다.
4
Gradle sync failed: 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.
		Consult IDE log for more details (Help | Show Log) (1m 37s 807ms)
이것은gradle이 4.4버전으로 업그레이드된 후 일부 API를 조정했기 때문이다.
each () 와 outputFile () 방법은 각각 all () 와 outputFileName으로 수정되었습니다.
원본gradle 파일에서
        variant.outputs.each { output ->
            output.outputFile = new File(output.outputFile.parent, "APPName" + "-" + buildType.name + "-v" +
                    defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk");
        }
    }

수정된 해당 컨텐트는
android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "cep" + "-" + buildType.name + "-" + releaseTime() + "-v" + defaultConfig.versionName + "-" + defaultConfig.versionCode + ".apk";
        }
    }

좋은 웹페이지 즐겨찾기