Zipalign - Command not found - MAC terminal


Zipalign - Command not found - MAC terminal



When I try to run Zipalign on an apk I get the error "Command not found"


"Command not found"



I am not that familiar with using terminal commands on the MAC but I have navigated to the SDK/Tools folder and run the following command:


zipalign -v 4 Project1.apk Project1-aligned.apk



I get Command not found



I have tried placing the apks in the Tools folder and same result.



Can someone help me to understand where the apks should be located and where I should run zipalign from?



Thanks, I am very frustrated about this as it seems so simple.




17 Answers
17



Perhaps the current directory is not in your path?



Try adding "./" before your command so


./zipalign -v 4 Project1.apk Project1-aligned.apk





I will try, thanks. I will also include the full path to the apk.
– Bill
Mar 16 '11 at 19:17





+1 for the correct answer, @Bill please mark this as correct answer if this solved your problem!! it always encourage people who answer questions.
– Prasad De Zoysa
Feb 28 '13 at 10:15






helped for me, thanks
– Zakharov Roman
Jul 11 '14 at 10:21





Worked as advertised for me.
– Ruepen
Jul 19 '16 at 21:08



You will find the zipalign tool at /path/to/sdk/build-tools/zipalign NOT in the tools folder anymore.


/path/to/sdk/build-tools/zipalign





This should be marked as proper answer!
– Bhavya Khurjawal
Aug 9 '16 at 12:32


~/Library/Android/sdk/build-tools/xxxx/zipalign



Drag this to terminal or save this in your path.
xxxx -> Version



You can find correct path with this command:


find ~/Library/Android/sdk/build-tools -name "zipalign"





You should receive a honor medal for this comment. You saved my life. Thanks, thanks and thanks again!!!
– Manuel Gozzi
Dec 27 '17 at 12:18



Zipalign is a command that located at $ANDROID_HOME/build-tools/{android-version}/.


$ANDROID_HOME/build-tools/{android-version}/



Hope it helped.





ANDROID, not ADROD. But, thanks for your answer, it helped me.
– Nikola
Apr 1 '16 at 18:39






Thank @Nikola correct me. I edited my answer. :-)
– NgaNguyenDuy
Apr 2 '16 at 20:19



A simple one-liner:



echo "export PATH=$PATH:~/Library/Android/sdk/build-tools/23.0.1/" >> ~/.bash_profile && . ~/.bash_profile


echo "export PATH=$PATH:~/Library/Android/sdk/build-tools/23.0.1/" >> ~/.bash_profile && . ~/.bash_profile



Make sure to replace 23.0.1 with your installed version


$ ls -l ~/Library/Android/sdk/build-tools/
total 0
drwxr-xr-x 23.0.1 <---



Now you should be able to use zipalign regardless of your current working dir



$ zipalign


$ zipalign





This is much more helpful.
– Tolga Can Günel
Dec 13 '16 at 6:39





drwxr-xr-x 23.0.1 <--- this line didn't give me the real version number, but after I fix it, it worked. Thank you.
– Serdar Değirmenci
Feb 5 '17 at 22:35





this is the real answer since by adding dir to PATH other tools in that dir like aapt can also be found
– Scott Stensland
Apr 19 at 14:56



Search it and reference it... I have it here and reference it like this:



/Users/lioncio/Desktop/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign bla bla bla (all the options of the command!)



And worked



Relax! , Just Use Locate Command in Terminal WHEREVER it is , it will come out


Locate


tom-MacBook-Air:kavform_app tom$ locate zipalign

/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign

/Users/tom/Software/android-sdk-macosx/docs/tools/help/zipalign.html



In my case it was burried over here


/Users/tom/Software/android-sdk-macosx/build-tools/24.0.1/zipalign -v 4 /Users/tom/kavwork/kavform/kavform_app/platforms/android/build/outputs/apk/android-release-unsigned.apk BrideToBe.apk





I think this works just wanted to let you know you get this the first time it is run and have to wait a bit: "Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear."
– asiammyself
Jan 26 at 0:14



cd android-sdk/build-tools/22.0.0/ - change directory to android sdk folder, build tools and choose version (I used 22.0.0).


cd android-sdk/build-tools/22.0.0/



Then at the prompt type:


./zipalign -v 4 /MyApp/android-x86-release-signed.apk ~/MyApp/android-x86-release-signedandzipped.apk



That worked for me. I tried the other solutions above with no success. I just had to run the command withn the proper folder, but that wasn't explained clearly in other resources I checked.



Navigate to the path of the zip align and include that with the command



/Users/ignatiusandrew/Library/Android/sdk/build-tools/25.0.2/zipalign 4 android-release-unsigned.apk igi.apk


/Users/ignatiusandrew/Library/Android/sdk/build-tools/25.0.2/zipalign 4 android-release-unsigned.apk igi.apk



Solution for Mac



This error basically means that the terminal wasn't able to find the zipalign file.
So you can either type in the full path for your zipalign file with the command (located in your Android build-tools folder)


/Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign -v 4 android-armv7-release-unsigned.apk helloWorld.apk;



If you do not know the location of the zipalign file, then just use this command


find ~/Library/Android/sdk/build-tools -name "zipalign"





is there a way to store the url that find returns? I'd like it to be dynamic
– Anjil Dhamala
Jun 7 at 18:08



If you are working on Windows, change the command prompt to point to the folder containing the zipalign.exe and then run the command. Also, I have found that you are not using the complete command:


zipalign [-f] [-v] 4 Input.apk Output.apk



I am using Windows with git bash/command promt



zipalign.exe needed to be configured in environment variables.



so include sdk folder 'build-tool' with android version folder you are using to build.


e.g. E:android-sdkbuild-tools22.0.1



it should contain 'zipalign.exe'. now you can user


zipalign -v 4 Project1.apk Project1-aligned.apk



from any location using command line tools.



thumb up for me so i can help more developers.



for me this worked perfectly, I copied the zipalign file from the android path to the folder where I wanted to run command and then typed ./zipalign -v 4 android-release-unsigned.sdk nameofapp.apk



Note: It was on Mac


%ANDROID_HOME%\build-tools\25.0.2\zipalign -v 4 .\platforms\android\build\outputs\apk\input.apk .\path\ output.apk





Hi, welcome to Stack Overflow! Consider expanding this answer to explain why you believe the users are unable to make this command work and how executing it like this fixes the issue. Also it may be worth adding some text detailing how a user could add this to their PATH so that they can execute it like OP tried in the question. Those 2 edits would make this answer to a very old question much more useful for people looking for a good answer. Thank you!
– William Patton
Mar 27 '17 at 13:39



add it to the path



on terminal



find path for zip align


find ~/Library/Android/sdk/build-tools -name "zipalign"



path: /Users/username/Library/Android/sdk/build-tools/26.0.1/zipalign



enter the path found in there


sudo nano /etc/paths



now on new terminal you can see zipalign reco



First,
if your android home is set, then you can just
cd $ANDROID_HOME
and
open . (This should be - /Users/username/Library/Android/, you can just cd to that path as well)


cd $ANDROID_HOME


open .



Next, navigate to "sdk/build-tools/25.0.3/" (version 25.0.3 in this case, yours may be a different version).



At your terminal (apk prompt), drag zipalign to the terminal and
...../zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk.
Should work fine.


...../zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk



Hope it helps.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy