cannot find zip-align when publishing app

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.

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

118978 次浏览

如果您安装,它将变得可用

Android SDK Build-tools Rev.20

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

编辑: 自从 Google 升级了 Android 版 SDK,新的 build-tools 确实解决了这个问题。因此,我鼓励大家按照彭日成在下面的帖子中的建议更新到 Android SDK Build-tools 20

我通过安装 Android SDK Build-tools 20修复了这个问题:

日食下拉菜单窗户Android SDK 管理器中,选中 Android SDK Build-tools Rev. 20,然后单击 安装 < em > n 包..。按钮开始安装。

zipalign被移动到 build-tools\19.1.0build-tools\20.0.0,我假设您应该使用其中之一,在取决于您的目标 SDK

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

Gradle (如果你正在使用 Android Studio)还没有被更新来反映这些变化,正如其他答案中所说的那样,将 zipalign二进制文件复制到 /sdk/tools/目前应该可以做到这一点。

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

compileSdkVersion 20

buildToolsVersion "20.0.0"

targetSdkVersion 20

如果您使用任何 compat 或者 support 库

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

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

检查 SDK 管理器,它已经安装了“ build-tools”。我在其默认状态,没有这样做。

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.

修复缺失拉链的教程

My fix worked copying zipalign.exe from sdk\build-tools\android-4.4W to Sdk 平台-工具, as shown in video linked by digiboomz, and 在 sdk 工具中复制它不起作用

如果在命令行中找不到 zipalign 命令,则将 zipalign 的文件路径添加到环境变量。如上所述,更改 exe 文件位置从来都不是好事。

对于 Windows 用户:

Add to User->PATH->"path to zipalign folder"

在我的情况下,它的路径是 C:\adt-bundle-windows-x86_64-20140702\sdk\build-tools\android-4.4W。 在那个文件夹中是 zipalign.exe

这个链接可以帮助您设置路径和理解它 http://www.voidspace.org.uk/python/articles/command_line.shtml#path

我通过卸载 Android SDK Platform (4.4 W)然后重新安装来修复它。 在安装之后,我还重新启动了 Eclipse。

如果你正在使用 gradle 只是更新你的 gradle 插件!

Change line in build.gradle from:

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

致:

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

对我有用。

注意,变量 buildToolsVersion (对我来说是“20.0.0”)必须与您的 build-tools 版本匹配。

祝你好运

我使用 Eclipse,但是在更新过程中出现了问题。
我检查了 ant 的 build.xml 希望在哪里找到 zipalign.exe。

In: C:\Development\Android\android-sdk\tools\ant\build.xml Zipalign 的定义是:

<property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" />

which indicates its expected in:

C:\Development\Android\android-sdk\build-tools\18.0.1

此目录对应于“ Android SDK Manager”中显示的“ Android SDK Build-tools”的最高版本。这就是我复制 zipalign.exe 的地方(这是我从 Android Studio 安装中获得的!)和签名的应用程序现在自动拉链再次!

在我的案例中,SDK Build Tools 20已经安装好了。 我在 Tools 文件夹中复制了 zipalign.exe,但没有成功。

之后,我注意到我没有删除或重命名旧文件夹就更新了 Eclipse。

所以我照做了:

1)重命名旧 Eclipse 文件夹 2)重启 Eclipse

Eclipse 要求更正 Android 的首选项,因为问题出在 Eclipse,它仍然试图使用旧的文件夹

在 Mac 上,我做了以下操作:

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

  2. 按下 Ctrl-打开允许应用程序从互联网

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

解决这个问题的步骤,

  1. 安装最新版本的 Android SDK Build-Tools
  2. 检查 android-sdk build-tools 文件夹中是否有 zipalign.exe,例如 android-sdk build-tools 21.1.0
  3. 在一些老版本的 android 中,你可能找不到 zipalign.exe。不要惊慌,检查任何其他版本的 zipalign 可用。
  4. 打开 project.properties 文件并配置 build-tools,使其指向 zipalign.exe 所在的位置。
  5. 重新启动您的日食和尝试再次出口。它应该工作。

在 Android Studio 1.0中,你必须使用 zipAlignEnabled true

我通过 RUN 作为 Administrator@your SDK Manager.exe 在目录 C: Program Files Android SDK 中解决了这个问题

after that u'll get updated build tools an any repository

我用了 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

Mac/Linux:

这对我很有用(您可能希望用构建工具的版本替换 22.0.1) :

编辑: ~/. 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

然后跑:

source ~/.bashrc

或者关闭终端,重新开始。

在使用 OSX 10.10.5的 Mac 上,Android Studio 和 SDK 安装的路径是

/Users/mles/Library/Android/sdk/build-tools/23.0.1/zipalign

通常 zipalign.exe 接近“ Android Manager”(也可以是“ Android”、“ Android SDK”等) ,所以你可以在 windows 搜索中使用 search for "Android Manager",并在命令和 < em > 开放档案位置 之上给出一个 右击。 你可能在: 什么 Android\android-sdk\tools。然后只是必要返回一个文件夹,去 < em > Android Android-sdk build-tools 23.0.3 。 The zipalign is there, you maybe be not able to use it with double-click, so you have to copy all the path of the zipalign file to use in < em > CMD , the final code that you have to input will be something like:

C: 用户 heitor AppData Local Android-sdk build-tools 23.0.1 zipalign.exe-v 4 Android.apk android2.apk

Google 用构建工具版本23.0.3修复了这个错误 现在 zipalign 包装正确,一切工作正常。

Zipalign Gradle 任务自 Android Plugin for Gradle,2.2.0修订版(2016年9月)以来已被弃用。

如果希望继续使用它,请将 android.useOldPackaging= true 添加到 gradle.properties 文件中。

Click 给你 for detailed explanation.

通过采用新的默认打包管道来提高构建性能,该管道在一个任务中处理压缩、签名和 zipalingin。可以通过将 android.useOldPackaging= true 添加到 gradle.properties 文件中来恢复使用旧的打包工具。在使用新的打包工具时,zipalignDebug 任务不可用。但是,您可以通过调用 createZipAlignTask (String taskName、 File inputFile、 File outputFile)方法自己创建一个。 除了传统的 JAR 签名之外,APK 签名现在还使用 APK 签名方案 v2。所有 Android 平台都接受最终的 APK。签名后对这些 APK 的任何修改都会使它们的 v2签名失效,并阻止在设备上安装。 引用原文

当我完全绝望的时候,我做了以下事情,这让我找到了 正式 Zipalign.exe。简短的回答是使用官方(但不是公开的)部分网站的链接:

https://dl.google.com/android/repository/build-tools_r28-rc1-windows.zip

如果你在2018年后使用这个接待处,你可能需要完整的解释:

  1. 打开 Android Studio,然后开始

    Android Studio->Tools->Android->SDK Manager->Android SDK->SDK update site
    
  2. Write in text editor link and open it in the browser. In my case the first link worked for me:

    https://dl.google.com/android/repository/repository2-1.xml
    
  3. Look for the latest package build-tools. In my case, it was build-tools_r28-rc1-windows.zip, but you can find the latest in your time

    Ctrl+F build-tools_
    
  4. Substitute in the URL the last part with the found package name like I did:

    https://dl.google.com/android/repository/build-tools_r28-rc1-windows.zip
    
  5. Download the package, unzip it and fortunately find official file:

    zipalign.exe
    

If it helps you, your feedback is wellcome.

I've fixed this issue by doing this:

打开 Android Studio > 参数设置 > SDK Tools 并检查“ Android SDK Build-Tools”