How to get zipalign for mac?
Asked Answered
F

3

16

I already have a release unsigned version apk and I am trying to sign it on my mac. On the last step it suggests to zipalign the signed apk but mac doesn't have zipalign.

I did 'brew search ' still can't find it. I searched online and can't find standalone zipalign script. I even downloaded around 90M Android sdk tool from http://developer.android.com/sdk/index.html#Other but still found no zipalign inside.

So my question is, given you an "apk" file to sign on mac, how to get through the last "zipalign" step?

Feuar answered 2/5, 2015 at 5:12 Comment(4)
possible duplicate of Zipalign - Command not found - MAC terminalWycoff
Are you indicating in order to use 'zipalign' I have to download 250M android studio and install it on mac? Cause all those posts mentioned some sort of android sdk install path.Feuar
I think so yes but no guaranteeWycoff
if you have the SDK installed you should be able to do "android zipalign -v file.apk dest.apk" on your command lineVibrissa
F
34

Thanks the info from RC.

I finally got through this. I did in following steps:

  1. Download 250M+ android studio ide dmg from official site. Drag it into Application folder
  2. Open it, and it automatically downloads a lot of additional stuff
  3. I even created a empty new project.

Then in certain step(I am not sure which step) it created zipalign here:

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

If you only need "zipalign", you don't need to redo those steps, which takes time and disk space. I extracted it into the github(Can't believe no one has extracted it -_- ):

https://github.com/catccaatt/zipalign

Feuar answered 2/5, 2015 at 7:21 Comment(1)
Mac users: If you get an error similar to: unable to execute ./zipalign: Bad CPU type in executable, you may need the 64bit version of ZipAlign. Available here: github.com/spanishsnapper/zipalign (extracted from Studio 29.0.2)Sino
F
15

From your Mac terminal:

Add adb to command line path:

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile

Add build tools to command line path:

echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/build-tools/28.0.2' >> ~/.bash_profile

Refresh command line with:

source ~/.bash_profile

Then you can run it with:

zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
Floranceflore answered 20/9, 2018 at 10:34 Comment(2)
make sure build-tools/version matches your installed version mine was 28.0.3.Cracow
You can use find ~/Library/Android/sdk/build-tools -name "zipalign" to find the zipalign path in your systemCracow
N
0

Expecting that you already have AndroidSDK, then just use this in terminal sudo ln -s ~/Library/Android/sdk/build-tools/34.0.0/zipalign /usr/local/bin/

Narcoanalysis answered 9/5 at 21:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.