android {
...
buildTypes {
release {
...
debuggable true
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
applicationVariants.all { variant ->
def appName = variant.applicationId.replace('.', '-')
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "${appName}-${variant.versionName}-${variant.versionCode}.apk"
}
}
}
lintOptions {
abortOnError false
}
}
}
}
通过以上步骤,可以帮助您解决Android发布版本编译失败,但调试版本编译成功的问题。