Android Studio 2.2更新:对齐的APK(zipAlign)不是使用新的Gradle插件2.2.0生成的 [英] Android Studio 2.2 update: aligned APK (zipAlign) not generated using the new Gradle Plugin 2.2.0
问题描述
在将Android Studio更新至2.2版后,我还得到了Gradle Plugin的更新(2.1.3版):
...
classpath'com.android.tools.build:gradle:2.2.0'
...
我看到未对齐的变体APK文件,但其他变体不再生成。我尝试启用zip对齐:
buildTypes {
发布{
minifyEnabled false
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix' .debug'
}
}
但没有任何变化。任何想法?
我解决了转回到
classpath 'com.android.tools.build:gradle:2.1.3'
在项目级别 build.gradle
。
编辑(20160922):
感谢Fayder Florez 的回应。这是正确的,构建环境现在只生成一个apk( https:// code但是使用代码(即使用
来重命名de输出文件名称 .google.com / p / android / issues / detail?id = 212591 ) code> VERSION CODE 和 VERSION NAME
):
android.applicationVariants.all {variant - >
variant.outputs.each {输出 - >
def padVersionCode = variant.versionCode.toString();
padVersionCode = padVersionCode.padLeft(5,'0')
def newApkName =$ {output.baseName} _ $ {padVersionCode} - $ {variant.versionName}
$ b $如果(!output.zipAlign)
newApkName = newApkName +_unaligned
newApkName = newApkName +.apk
output.outputFile = new File(output.outputFile。 parent,newApkName)
}
}
我添加了_unaligned到输出文件名,所以我想 output.zipAlign
是 false
。
所以输出文件是否真正对齐?
编辑(20161013)
感谢ending 0421 ,并建议使用构建工具检查apk: zipalign -c -v 4路径/文件名
现在我现在已经正确生成APK zipalign命令syays:
验证成功
到此论坛: https://code.google.com/p/android / issues / detail?id = 212591
我们不再生成未对齐的apks。作为改进速度的一部分,我们生成已经对齐的apk。所以,而不是两个,你只是得到最后一个。
@ yair.kikielka谢谢。
After updating Android Studio to version 2.2 I also got an update for the Gradle Plugin (it was 2.1.3):
...
classpath 'com.android.tools.build:gradle:2.2.0'
...
I see the unaligned variant APK file but other variants are not generated anymore. I tryed to enable the zip align:
buildTypes {
release {
minifyEnabled false
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
applicationIdSuffix '.debug'
}
}
but nothing changes. Any ideas?
I "solved" turning back to
classpath 'com.android.tools.build:gradle:2.1.3'
in the project level build.gradle
.
EDIT (20160922):
Thanks to Fayder Florez for his response. It's correct, the build environment now produce only one apk (https://code.google.com/p/android/issues/detail?id=212591).
But using by code (that rename de output file name using VERSION CODE
and VERSION NAME
):
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def padVersionCode = variant.versionCode.toString();
padVersionCode = padVersionCode.padLeft(5, '0')
def newApkName = "${output.baseName}_${padVersionCode}-${variant.versionName}"
if (!output.zipAlign)
newApkName = newApkName + "_unaligned"
newApkName = newApkName + ".apk"
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}
I get the "_unaligned" appended to the output file name, so I suppose that output.zipAlign
is false
.
So is the output file really aligned?
EDIT (20161013)
Thanks to ending0421 and it's suggestion to check the apk using the build tool:
zipalign -c -v 4 path/fileName
Now I now that the APK is generated correctly and the zipalign command syays:
Verification succesful
According to this forum: https://code.google.com/p/android/issues/detail?id=212591
"Hi, we don't generate unaligned apks any more. As part of the improvements to speed things, we generate the apk already aligned. So, instead of two, you just get the final one.
@yair.kikielka Thanks."
这篇关于Android Studio 2.2更新:对齐的APK(zipAlign)不是使用新的Gradle插件2.2.0生成的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!