Android 发布应用程序时找不到 zip-align

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24442213/
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 08:09:31  来源:igfitidea点击:

cannot find zip-align when publishing app

androidzipalign

提问by JMRboosties

cannot.find.zip.align=The zipalign tool was not found in the SDK.

Please update to the latest SDK and re-export your application
or run zipalign manually.

Aligning applications allows Android to use application resources
more efficiently.

This is the message I received when I tried to publish my app. I'm using the latest revision of Android SDK Tools (23 which was released today) and SDK Platform-tools (20 which was also released today). I got an APK out of it, but if I tried to upload it to Google Play I got an error complaining that it is not zip aligned.

这是我尝试发布应用程序时收到的消息。我正在使用最新版本的 Android SDK Tools(今天发布的 23)和 SDK Platform-tools(今天发布的 20)。我从中得到了一个 APK,但是如果我尝试将它上传到 Google Play,我会收到一个错误,抱怨它不是 zip 对齐的。

Running zipalign manually fixes the apk, but does anyone know what causes this and how to fix it?

手动运行 zipalign 修复了 apk,但有谁知道是什么原因造成的以及如何修复它?

回答by Kuma

I had the same problem. And to fix it, I copy the Zipalign file from sdk/build-tools/android-4.4W folder to sdk/tools/

我有同样的问题。为了修复它,我将 Zipalign 文件从 sdk/build-tools/android-4.4W 文件夹复制到 sdk/tools/

Edited:Since Google updated SDK for Android, new build-tools does fix this problem. So I encouraged everyone to update to Android SDK Build-tools 20as suggested by Pang in the post below.

编辑:由于谷歌更新了 Android SDK,新的构建工具确实解决了这个问题。所以我鼓励大家按照Pang 在下面的帖子中的建议更新到Android SDK Build-tools 20

回答by Pang

I fixed it by installing Android SDK Build-tools 20:

我通过安装 Android SDK Build-tools 20 修复了它:

In EclipsePull Down MenuWindowAndroid SDK Manager, check Android SDK Build-tools Rev. 20, then click the Install npackage(s)…button to start installing.

EclipsePull Down MenuWindowAndroid SDK Manager 中,选中Android SDK Build-tools Rev. 20,然后单击Install npackage(s)...按钮开始安装。

回答by suno

It becomes usable if you install

如果你安装它变得可用

Android SDK Build-tools Rev.20

回答by digiboomz

I decided to just make a video for this..I kept pasting it into tools but alas that was not working for me. I moved it to platform-tools and voila publishing right away..must restart eclipse afterwards.

我决定为此制作一个视频..我一直将它粘贴到工具中,但可惜这对我不起作用。我将它移到平台工具,然后立即发布……之后必须重新启动 eclipse。

Tutorial for fixing missing zipalign

修复丢失 zipalign 的教程

回答by loganyu

I used the full path of zipalign. For mac, I found the executable file in Finder and clicked on it. Then, to publish my app I ran

我使用了 zipalign 的完整路径。对于mac,我在Finder 中找到了可执行文件并点击它。然后,为了发布我的应用程序,我跑了

/Users/username/development/sdk/tools/zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

instead of

代替

zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

回答by Petter Kjelkenes

Mac / Linux:

Mac/Linux:

This worked for me (you might want to replace 22.0.1with version of your build tools):

这对我有用(你可能想用你的构建工具版本替换22.0.1):

Edit: ~/.bashrc

编辑:~/.bashrc

export ANDROID_HOME=~/Android/Sdk/
export ANDROID_TOOLS=~/Android/Sdk/tools/
export ANDROID_BUILD_TOOLS=~/Android/Sdk/build-tools/22.0.1/
export ANDROID_PLATFORM_TOOLS=~/Android/Sdk/platform-tools/
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS:$ANDROID_BUILD_TOOLS

And run:

并运行:

source ~/.bashrc

or just close terminal and start it again.

或者只是关闭终端并重新启动它。

回答by Anna Billstrom

On a Mac, I did the following:

在 Mac 上,我执行了以下操作:

  1. Find it on o/s (I had already downloaded build tools for 19 and 20)

  2. Press Ctrl-Open to allow apps from the internet

  3. Move it from sdk/build-tools/android-4.4W folder to sdk/tools/. Whew.

  1. 在 o/s 上找到它(我已经下载了 19 和 20 的构建工具)

  2. 按 Ctrl-Open 以允许来自 Internet 的应用程序

  3. 将其从 sdk/build-tools/android-4.4W 文件夹移动到 sdk/tools/。哇。

回答by DooMMasteR

With the SDK update to 20, version 20 of the build and platform tools and 23 of the sdk tolls, Google has moved a lot of things.

随着 SDK 更新到 20、构建和平台工具的 20 版本以及 sdk 收费的 23,Google 已经移动了很多东西。

Gradle (if you are using Android Studio) however has not yet been updated to reflect those changes, as stated in other Answers copying the zipalignbinary to /sdk/tools/should do the trick for now.

Gradle(如果您使用的是 Android Studio)但是尚未更新以反映这些更改,正如其他答案中所述,将zipalign二进制文件复制到/sdk/tools/现在应该可以解决问题。

UPDATE:since Android Studio 0.8.1 got released the issue seems fixed now…
you only need to update your build.gradleand it should work fine again

更新:自从 Android Studio 0.8.1 发布以来,这个问题现在似乎已经解决了……
你只需要更新你的build.gradle,它应该可以再次正常工作

compileSdkVersion 20

compileSdkVersion 20

buildToolsVersion "20.0.0"

buildToolsVersion "20.0.0"

targetSdkVersion 20

targetSdkVersion 20

and if you use any compat or support library

如果您使用任何兼容或支持库

compile 'com.android.support:appcompat-v7:20.+'

compile 'com.android.support:appcompat-v7:20.+'

compile 'com.android.support:support-v4:20.+'

compile 'com.android.support:support-v4:20.+'

回答by user3802203

Check in the SDK manager, that it has installed the "build-tools". Mine in its default state, did not do this.

检查 SDK 管理器,它是否已安装“构建工具”。我的默认状态下,没有这样做。

回答by centy

If you are using gradle just update ypur gradle plugin!

如果您正在使用 gradle 只需更新 ypur gradle 插件!

Change line in build.gradle from:

将 build.gradle 中的行更改为:

classpath 'com.android.tools.build:gradle:0.9.+'

to:

到:

classpath 'com.android.tools.build:gradle:0.11.+'

It works for me.

这个对我有用。

Note that variable buildToolsVersion (for me "20.0.0") must match your version of build-tools.

请注意,变量 buildToolsVersion(对我来说是“20.0.0”)必须与您的构建工具版本相匹配。

Good luck :)

祝你好运 :)