Android 您上传的 APK 不是 zip 对齐错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22681907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:20:06  来源:igfitidea点击:

You uploaded an APK that is not zip aligned error

androidgoogle-playapk

提问by Anas

I have just finished and signed the apk through android studio, then I have did an apk protect through apkprotect.com when I am trying to upload the apk to play store I got this error " You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again. " if I upload the original apk I got no errors,

我刚刚完成并通过 android studio 签署了 apk,然后当我尝试将 apk 上传到 Play 商店时,我通过 apkprotect.com 进行了 apk 保护,我收到此错误“您上传了一个未对齐的 APK。你将需要在您的 APK 上运行一个 zip 对齐工具并再次上传。”如果我上传原始 APK,我就没有错误,

I have tried to add zipalign true in the build.gradle but nothing happened I have tried also disable and enable proguard .

我试图在 build.gradle 中添加 zipalign true 但什么也没发生我也试过禁用和启用 proguard 。

回答by Minas

You can run zipalign manually in command line:

您可以在命令行中手动运行 zipalign:

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

Note that zipalign is located inside ${sdk.dir}\tools

请注意,zipalign 位于 ${sdk.dir}\tools 内

For more details visit zipalign

有关更多详细信息,请访问zipalign



[Update]

[更新]

Also, If you need to sign it you can run:

另外,如果您需要签名,您可以运行:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURKEYSTORE unsigned.apk alias_name

(jarsigneris located inside java JDK_HOME/bin)

jarsigner位于 java JDK_HOME/bin 内)

回答by Derek Gogol

I got the same "You uploaded an APK that is not zip aligned... blah, blah" error when by mistake I tried to upload a DEBUG version of my .apk file to Google Play. It's a bit misleading error because the real problem is that you cannot distribute a debug version which additionally is not signed with your Google Android Developer key. (You can only upload an .apk compiled as release version, and it must be signed, which happens in the same step, at least if you're using Eclipse).

当我错误地尝试将我的 .apk 文件的调试版本上传到 Google Play 时,我得到了同样的“你上传了一个没有对齐的 APK......等等,等等”错误。这是一个有点误导性的错误,因为真正的问题是您无法分发未使用您的 Google Android 开发人员密钥签名的调试版本。(您只能上传编译为发布版本的 .apk,并且必须对其进行签名,这发生在同一步骤中,至少在您使用 Eclipse 时是如此)。

Make sure you distribute an .apk file which is your Signed Release version, as described here:

确保您分发了一个 .apk 文件,它是您的签名发布版本,如下所述:

http://developer.android.com/tools/publishing/app-signing.html#releasecompile

http://developer.android.com/tools/publishing/app-signing.html#releasecompile

回答by Paul Gregtheitroade

This question and its answers are old; so we expect things to change. As of today, the zipalign tool is in the ANDROID_HOME directory under build-tools/[version]/ so my path is currently:

这个问题及其答案很旧;所以我们期待事情会发生变化。截至今天,zipalign 工具位于 build-tools/[version]/ 下的 ANDROID_HOME 目录中,因此我的路径当前为:

/android-sdk/build-tools/22.0.0/zipalign

Using the zipalign tool is not necessarily the answer here though, what you actually need to do is sign your apk.

使用 zipalign 工具不一定是这里的答案,您实际上需要做的是对您的 apk 进行签名。

回答by jony89

I was using Cordova, uploaded a signed APK but still got this error.

我正在使用 Cordova,上传了一个签名的 APK,但仍然出现此错误。

The ziptool is what helped me, it's located at ~AndroidSDK\build-tools\24.0.0\zipalign.exe

ziptool 对我有帮助,它位于 ~AndroidSDK\build-tools\24.0.0\zipalign.exe

So for example :

例如:

"~\AndroidSDK\build-tools.0.0\zipalign.exe" -f -v 4 android-release-signed.apk android-release-signed-zipaligned.apk

回答by Stack Em Up

Steps if using Xamarin for VS2017:

如果使用 Xamarin for VS2017 的步骤:

  1. Build project
  2. Right click and Archiveproject
  3. Use Ad Hocdistribution channel
  4. Sign your APK with your Signing Identity and Save Asto produce an APK that is ZIP aligned.
  1. 构建项目
  2. 右键单击并Archive投影
  3. 使用Ad Hoc分销渠道
  4. 使用您的签名标识Save As对您的 APK 进行签名,并生成一个 ZIP 对齐的 APK。

Your APK can be uploaded to Google Play.

您的 APK 可以上传到 Google Play。

回答by Helzgate

I was using Cordova and the command line getting this error. I opened the project in Android Studio and used Android Studio to build the signed apk and the error went away.

我正在使用 Cordova 并且命令行收到此错误。我在 Android Studio 中打开了该项目并使用 Android Studio 构建了已签名的 apk,错误消失了。

回答by OXiGEN

When using the Cordova node.js CLI without going through Android Studio, it is necessary to update the PATHenvironmental variable to include the android build tools:

在不通过 Android Studio 的情况下使用 Cordova node.js CLI 时,需要更新PATH环境变量以包含 android 构建工具:

%ANDROID_HOME%\build-tools.0.2

Obviously the version number will change over time. Remember to close any CLI windows and re-open them to recognize the newly added path.

显然,版本号会随着时间而改变。请记住关闭所有 CLI 窗口并重新打开它们以识别新添加的路径。