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

来源:互联网 发布:阿里云 svn服务器搭建 编辑:程序博客网 时间:2024/06/05 10:59

针对1.0中新版Gradle已经做了以下替换:

Renamed a few properties to make things more consistent.BuildType.runProguard                 ->  minifyEnabledBuildType.zipAlign                    -> zipAlignEnabledBuildType.jniDebugBuild               -> jniDebuggableBuildType.renderscriptDebug           -> renderscriptDebuggableProductFlavor.renderscriptSupportMode -> renderscriptSupportModeEnabledProductFlavor.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


0 0
原创粉丝点击