问题
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?
回答1:
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/
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 20 as suggested by Pang in the post below.
回答2:
I fixed it by installing Android SDK Build-tools 20:
In Eclipse → Pull Down Menu → Window → Android SDK Manager, check Android SDK Build-tools Rev. 20, then click the Install n package(s)… button to start installing.
回答3:
It becomes usable if you install
Android SDK Build-tools Rev.20
回答4:
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.
Tutorial for fixing missing zipalign
回答5:
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
/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
回答6:
Mac / Linux:
This worked for me (you might want to replace 22.0.1 with version of your build tools):
Edit: ~/.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.
回答7:
On a Mac, I did the following:
Find it on o/s (I had already downloaded build tools for 19 and 20)
Press Ctrl-Open to allow apps from the internet
Move it from sdk/build-tools/android-4.4W folder to sdk/tools/. Whew.
回答8:
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.
Gradle (if you are using Android Studio) however has not yet been updated to reflect those changes, as stated in other Answers copying the zipalign
binary to /sdk/tools/
should do the trick for now.
UPDATE: since Android Studio 0.8.1 got released the issue seems fixed now…
you only need to update your build.gradle
and it should work fine again
compileSdkVersion 20
buildToolsVersion "20.0.0"
targetSdkVersion 20
and if you use any compat or support library
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v4:20.+'
回答9:
Check in the SDK manager, that it has installed the "build-tools". Mine in its default state, did not do this.
回答10:
If you are using gradle just update ypur gradle plugin!
Change line in build.gradle from:
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.
Good luck :)
回答11:
With Android Studio 1.0 you have to use zipAlignEnabled true
回答12:
My fix worked copying zipalign.exe from sdk\build-tools\android-4.4W to sdk\platform-tools, as shown in video linked by digiboomz, and did not work copying it in sdk\tools
回答13:
If zipalign command is not found from Command-Line add file path of zipalign to environmental variables. As mentioned above, it's never good to change exe file location.
For Windows users:
Add to User->PATH->"path to zipalign folder"
In my case it path was C:\adt-bundle-windows-x86_64-20140702\sdk\build-tools\android-4.4W
.
In that folder is zipalign.exe
This link can help you with setting path and understanding it http://www.voidspace.org.uk/python/articles/command_line.shtml#path
回答14:
I use Eclipse and this broke during an update. Here's what worked for me as the answers above did not.
I checked where ant's build.xml expected to find zipalign.exe.
In: C:\Development\Android\android-sdk\tools\ant\build.xml
zipalign is defined as:
<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
This directory corresponds to the highest version of the 'Android SDK Build-tools' displayed as installed in the 'Android SDK Manager'. So, that's where I copied zipalign.exe (which I obtained from an Android Studio installation!) and signed apps are now automatically zipaligned again!
回答15:
i solved by RUN as Administrator @ your SDK Manager.exe in directory C:\Program Files\Android SDK
after that u'll get updated build tools an any repository
回答16:
Steps to fix this,
- Install latest version of Android SDK Build-Tools
- Check if zipalign.exe is available in folder android-sdk\build-tools\ e.g. android-sdk\build-tools\21.1.0\
- In some older version of android you may not find zipalign.exe. Do not panic, check any other verion in which zipalign is available.
- Open your project.properties file and configure build-tools to point to the in which zipalign.exe is present. e.g. sdk.buildtools=21.1.0.
- Restart your eclipse and try exporting again. It should work.
回答17:
On a mac with OSX 10.10.5,Android Studio and SDK installed the path is
/Users/mles/Library/Android/sdk/build-tools/23.0.1/zipalign
回答18:
Zipalign gradle task is deprecated since Android Plugin for Gradle, Revision 2.2.0 (September 2016).
If you want to keep using it, add android.useOldPackaging=true to your gradle.properties file.
Click here for detailed explanation.
Improves build performance by adopting a new default packaging pipeline which handles zipping, signing, and zipaligning in one task. You can revert to using the older packaging tools by adding android.useOldPackaging=true to your gradle.properties file. While using the new packaging tool, the zipalignDebug task is not available. However, you can create one yourself by calling the createZipAlignTask(String taskName, File inputFile, File outputFile) method. APK signing now uses APK Signature Scheme v2 in addition to traditional JAR signing. All Android platforms accept the resulting APKs. Any modification to these APKs after signing invalidates their v2 signatures and prevents installation on a device. Blockquote
回答19:
zipalign
was moved to build-tools\19.1.0
and build-tools\20.0.0
, I assume you should use one of them in depend of your target SDK
回答20:
I fixed it by uninstalling Android SDK Platform (4.4W) and then reinstalling it. I also restarted Eclipse after the installation.
回答21:
In my case SDK Build Tools 20 were already installed. I copied zipalign.exe in Tools folder but without success.
After that I noticed that I updated Eclipse without removing or renaming the old folder.
So I did:
1) Renamed old Eclipse folder 2) Restarted Eclipse
Eclipse asked to correct Android preferences because problem was Eclipse, that was still trying to use the old folder
回答22:
Google fix this mistake with the build tools version: 23.0.3 Now zipalign is packaged properly, and everything works fine.
回答23:
Normally the zipalign.exe is close of the "Android manager"(also, "Android", "Android SDK" etc), so you can search for "Android Manager" in windows search and give a righ-click above the command and open file location. You probably are in: something\ Android\android-sdk\tools. Then is just necessary return a folder and go to 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 CMD, the final code that you have to input will be something like:
C:\Users\heitor\AppData\Local\Android\android-sdk\build-tools\23.0.1\zipalign.exe -v 4 android.apk android2.apk
回答24:
When I was completely desperate, I did the following, that allowed me to find official zipalign.exe. The short answer is to use the link from official (but not public :-) part of of the site:
https://dl.google.com/android/repository/build-tools_r28-rc1-windows.zip
If you use this recepy after 2018, you probably need the full explanation:
Open Android Studio and go
Android Studio->Tools->Android->SDK Manager->Android SDK->SDK update site
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
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_
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
Download the package, unzip it and fortunately find official file:
zipalign.exe
If it helps you, your feedback is wellcome.
来源:https://stackoverflow.com/questions/24442213/cannot-find-zip-align-when-publishing-app