cannot find zip-align when publishing app
Asked Answered
E

25

123
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?

Efficacious answered 27/6, 2014 at 0:15 Comment(1)
The latest sdk tools(23) hasn't been packaged properly. Faced problems with many tools on this release.Faultfinder
G
224

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.

Giza answered 27/6, 2014 at 7:46 Comment(8)
It must be a copy of the file and not a symbolic link in OSX. I used a sym-link (which is usually enough) and it was still not found.Ethbinium
I found it under - sdk\build-tools\20.0.0Tumulus
Don't copy the exe from another directory. Use the SDK Manager to install SDK Build tools v20Murr
When using ant build-release, one need to add sdk.buildtools=19.1.0 or =20.0.0 to project.properties. Also note that zipalign properties set has been changed in the ANT build.xml to point on the righ tool chain version.Nervous
As mentioned in some of the answers that you need to install Android SDK Build-tools Rev. 20. I did. But still getting the same error. Then i have to copy Zipalign from "sdk/build-tools/20.0.0" to "sdk/tools/"Ruffo
I downvoted this - the correct answer is to get the build tools version 20 (as in the answer given by Pang)Helices
Now Zipalign tool is present at this location at /path/to/sdk/build-tools/zipalign.exeCalculated
Zipalign is deprecated as of Android Plugin for Gradle, Revision 2.2.0 (September 2016). See my answer below for details. https://mcmap.net/q/75931/-cannot-find-zip-align-when-publishing-appLithometeor
H
96

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

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

Hollinger answered 27/6, 2014 at 9:35 Comment(2)
I had to restart eclipse after doing thisRetina
Rev. 23.0.0 fix this issue... It's useful for latest buildSquier
K
20

It becomes usable if you install

Android SDK Build-tools Rev.20
Kimble answered 27/6, 2014 at 5:37 Comment(0)
P
8

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

Pyemia answered 5/7, 2014 at 19:35 Comment(2)
Great video thanks, for me it worked by adding the zipalign to the tools and not platform toolsTumulus
This link did help me, but instead of moving the zipalign.exe from the build-tools to the platform-tools, I just added the build-tools folder the PATH envBedouin
E
8

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
Epidemiology answered 23/1, 2015 at 22:37 Comment(1)
For windows (my zipalign path): C:\Users\Machine\AppData\Local\Android\Sdk\build-tools\27.0.3\zipalign.exe My Example cmd & 'C:\Users\Machine\AppData\Local\Android\Sdk\build-tools\27.0.3\zipalign.exe' -v 4 './platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk' './platforms/android/app/build/outputs/apk/release/app-release-signed.apk'Atrophy
I
8

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.

Interlard answered 2/6, 2015 at 19:55 Comment(1)
just one edit: you missed the "export" in last line. :-)Chatelain
D
7

On a Mac, I did the following:

  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.

Delectation answered 9/10, 2014 at 19:27 Comment(0)
C
4

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.+'

Cu answered 27/6, 2014 at 13:53 Comment(2)
Point of clarification, move the binary from your android sdk folder to the android studio's sdk folder. Like: C:\Program Files (x86)\Android\android-sdk\tools\zipalign.exe to C:\Program Files (x86)\Android\android-studio\sdk\tools\zipalign.exeSuellensuelo
google has updated android studio (0.8.1) and the issues do not occur anymore with this newer versionCu
D
3

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

Dynamometer answered 3/7, 2014 at 14:52 Comment(0)
B
3

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 :)

Bandog answered 6/8, 2014 at 19:16 Comment(0)
U
2

With Android Studio 1.0 you have to use zipAlignEnabled true

Unmake answered 5/12, 2014 at 19:27 Comment(0)
U
1

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

Undetermined answered 15/7, 2014 at 16:12 Comment(0)
C
1

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

Carincarina answered 5/8, 2014 at 9:42 Comment(0)
T
1

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!

Travancore answered 14/8, 2014 at 9:51 Comment(0)
F
1

Steps to fix this,

  1. Install latest version of Android SDK Build-Tools
  2. Check if zipalign.exe is available in folder android-sdk\build-tools\ e.g. android-sdk\build-tools\21.1.0\
  3. In some older version of android you may not find zipalign.exe. Do not panic, check any other verion in which zipalign is available.
  4. 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.
  5. Restart your eclipse and try exporting again. It should work.
Foregoing answered 2/11, 2014 at 5:46 Comment(0)
K
1

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

Kline answered 13/1, 2015 at 2:7 Comment(0)
A
1

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
Announcer answered 21/9, 2015 at 13:11 Comment(0)
L
1

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

Lithometeor answered 26/9, 2016 at 17:32 Comment(0)
I
0

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

Interest answered 27/6, 2014 at 12:30 Comment(0)
S
0

I fixed it by uninstalling Android SDK Platform (4.4W) and then reinstalling it. I also restarted Eclipse after the installation.

Safeguard answered 6/8, 2014 at 14:18 Comment(0)
I
0

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

Inurn answered 28/9, 2014 at 9:49 Comment(0)
V
0

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

Valedictorian answered 25/5, 2016 at 20:24 Comment(0)
F
0

Google fix this mistake with the build tools version: 23.0.3 Now zipalign is packaged properly, and everything works fine.

Flourishing answered 7/6, 2016 at 12:50 Comment(0)
C
0

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:

  1. Open Android Studio and go

    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.

Commonage answered 8/3, 2018 at 23:35 Comment(2)
Android Studio->Tools->Android->SDK Manager->Android SDK ->SDK Tools -> check "Android SDK Build-Tools 28-rc1",then apply,you will install the build tools, and you can find zipalign.exe in SDK\build-tools\28.0.0-rc1 after installed.Longley
You are right, It should be installed, but was not installed in my case. I checked. This recipe is for those who do not have this file after all attempts.Commonage
V
0

I've fixed this issue by doing this:

Open Android Studio > Preferences > SDK Tools and check "Android SDK Build-Tools"

Vonnievonny answered 10/1, 2020 at 17:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.