您的位置:首页 > 移动开发

Could not find property 'zipAlignEnabled' on com.android.build.gradle.internal.api.ApplicationVarian

2014-12-18 17:47 841 查看
针对1.0中新版Gradle已经做了以下替换:

Renamed a few properties to make things more consistent.
BuildType.runProguard                 ->  minifyEnabled
BuildType.zipAlign                    -> zipAlignEnabled
BuildType.jniDebugBuild               -> jniDebuggable
BuildType.renderscriptDebug           -> renderscriptDebuggable
ProductFlavor.renderscriptSupportMode -> renderscriptSupportModeEnabled
ProductFlavor.renderscriptNdkMode     -> renderscriptNdkModeEnabled


if (variant.zipAlignEnabled) {
def file = variant.outputFile
def fileName = file.name.replace("apk/" + applicationId + "-V" + versionName + "-" + versionCode + "-" + variant.name + "-" + buildTime() + "-unaligned.apk")
variant.outputFile = new File(file.parent, fileName)
}


但还是会报

Could not find property 'zipAlignEnabled' on com.android.build.gradle.internal.api.ApplicationVarian
修改方案:

if (variant.buildType.zipAlignEnabled) {
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "apk/" + applicationId + "-V" + versionName + "-" + versionCode + "-" + variant.name + "-" + buildTime() + "-unaligned.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
ldTime() + ".apk");
} else {
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "apk/" + applicationId + "-V" + versionName + "-" + versionCode + "-" + variant.name + "-" + buildTime() + ".apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}


效果:



参考链接:

http://stackoverflow.com/questions/27222688/could-not-find-property-zipalignenabled-on-com-android-build-gradle-internal-a

http://stackoverflow.com/questions/25997866/gradle-warning-variant-getoutputfile-and-variant-setoutputfile-are-deprecat
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐