升級as和gradle版本后趟咆,報錯了
A problem was found with the configuration of task ':app:createTongyongReleaseApkListingFileRedirect' (type 'ListingFileRedirectTask').
- In plugin 'com.android.internal.version-check' type 'com.android.build.gradle.internal.tasks.ListingFileRedirectTask' property 'listingFile' specifies file 'D:\項目地址\app\tongyong\release\output-metadata.json' which doesn't exist.
因為自定義了輸出目錄产场,output-metadata.json
文件找不到了隶垮。
原來的代碼
android.applicationVariants.all { variant ->
variant.outputs.all {
def aid = variant.applicationId.split("\\.")
def name = aid[aid.length - 1]
def buildEnv = env
def buildType = variant.buildType.name
def abi = getFilter(com.android.build.OutputFile.ABI)
if (abi == null) abi = "all"
def version = variant.versionName
def versionCode = variant.versionCode
def date = new Date()
def formattedDate = date.format('yyyyMMdd_HHmm')
outputFileName = "${name}" +
"${"_"}${buildEnv}" +
"${"_"}${buildType}" +
"${"_"}${abi}" +
"${"_"}${"v"}${version}" +
"${"_"}${"b"}${versionCode}" +
"${"_"}${formattedDate}.apk"
if (variant.buildType.name == "release") {
variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath
+ "/releaseOutputs")
}
}
}
兩個方法解決
1室囊、注釋掉自定義輸出目錄雕崩,使用默認目錄
// if (variant.buildType.name == "release") {
// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath
// + "/releaseOutputs")
// }
2、在下方加上融撞,跳過這個task
tasks.whenTaskAdded { task ->
if (task.name.contains("ReleaseApkListingFileRedirect")) { // 過濾release
task.enabled = false
}
}