When I try to run Zipalign on an apk I get the error "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.
You can find correct path with this command:
find ~/Library/Android/sdk/build-tools -name "zipalign"
Perhaps the current directory is not in your path?
Try adding "./" before your command so
./zipalign -v 4 Project1.apk Project1-aligned.apk
You will find the zipalign tool at /path/to/sdk/build-tools/<build-tools-version>/zipalign NOT in the tools folder anymore.
~/Library/Android/sdk/build-tools/xxxx/zipalign
Drag this to terminal or save this in your path.
xxxx -> Version
Zipalign is a command that located at $ANDROID_HOME/build-tools/{android-version}/.
Hope it helped.
A simple one-liner:
This adds a line in your profile, to add the directory which contains the zipalign executable to your path
Then reloads the 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
on the mac with the zsh console, my solution was
command 1)
find ~/Library/Android/sdk/build-tools -name "zipalign"
----------------------------------------------------------
/Users/macOs/Library/Android/sdk/build-tools/28.0.3/zipalign
/Users/macOs/Library/Android/sdk/build-tools/26.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/25.0.2/zipalign
/Users/macOs/Library/Android/sdk/build-tools/27.0.3/zipalign
command 2)
echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/28.0.3/" >> ~/.bash_profile && . ~/.bash_profile
command 3)
ls -l ~/Library/Android/sdk/build-tools/
command 4)
zipalign -v 4 app-release-unsigned.apk nameApp.apk
2hours resume for newbies (like me) :
If you type this command :
zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk app-release.apk
Witch gives you :
command not found: zipalign
It's maybe that the path is somewhere wrong.
If you have this :
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/apt" (-1)
It confirms that its not really as it should be. So, to execute zipalign and finally publish your app, you have to go in the correct repository and execute commande.
1. Go to the correct repo to execute command :
The path is cd /Users/xxxyour_user_namexxx/Library/Android/sdk/build-tools/xxxxx/
cd /Users/greg/Library/Android/sdk/build-tools/28.0.3
2. Execute your zipalign command, don't forget to precise the path of apk file :
Obviously, chance "greg" and "myapp" with your user name & app name.
./zipalign -v 4 /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk /Users/greg/Desktop/AppLocal/myapp/platforms/android/app/build/outputs/apk/release/app-release.apk
Hope it helps.
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
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
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
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"
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
cd android-sdk/build-tools/22.0.0/ - change directory to android sdk folder, build tools and choose version (I used 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
Alternatively, if you do not want to add a specific build tools folder to the path, in case it changes in the future, you can use the first result of find command:
$(find ~/Library/Android/sdk/build-tools -name "zipalign" | head -n 1) <your-zipalign-parameters>
It might be especially useful in a CI pipeline.
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
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)
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.
Hope it helps.
Downloaded zipalign-file from github
zipalign exec copy and paste in your Project1-aligned.apk directory
./zipalign -v 4 Project1.apk Project1-aligned.apk
In my case
I follow below answer
Change directory
/path/to/sdk/build-tools//zipalign
Type
./zipalign instead zipalign
In short ./zipalign is solution for me.
Solution for Jenkins
For Jenkins users using MacOS to build and sign mobile apps who are experiencing this error, the solution could be this:
At the stage where the signature is made:
withEnv(['PATH=/Users/jenkins/Library/Android/sdk/build-tools/29.0.3',
'ANDROID_SDK_ROOT=/Users/jenkins/Library/Android/sdk',
'JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home'])
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-sdk\build-tools\22.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.
Im trying to install Hadoop 2.7.1 on my current laptop running linux mint 17 right now following this guide: http://tecadmin.net/setup-hadoop-single-node-cluster-on-centos-redhat/#
However, when I am on step 4 i get:
$ ~/.bashrc
-su: /home/hadoopdev/.bashrc: No such file or directory
or when i try: $ vi .bashrc
it shows an empty window with ~ on the side
what am I doing wrong here?
Step 4 just says edit and append those lines at the end of the file.
There is not a problem if the file does not exist. Just open in up and insert those lines, then save.
I upgraded from cygwin 3 to 4.
Now I have the following strange behaviour that I did not experience before:
I have cygwin installed in c:\Tools\cygwin.
bash -c pwd produces different output when started from c:\Tools\cygwin than from any other dir:
c:\Tools>cygwin\bin\bash -c pwd
/cygdrive/c/Tools
c:\Tools>cd cygwin
c:\Tools\cygwin>bin\bash -c pwd
/
This is problematic for me because until now I bundled required cygwin binaries in a bin subdirectory to execute shell scripts on Windows.
That is I had batch files that invoke the shell script via bin/bash -f myscript.sh.
And these shell scripts do things like cd .. which does not work now as the current working dir is /!
A workaround is to move cygwin one subdirectory deeper, but I'd like to understand why cygwin behaves like this.
[EDIT]:
It gets even better:
c:\Tools\cygwin>cd bin
c:\Tools\cygwin\bin>bash -c pwd
/usr/bin
And ls when starting from c:\Tools\cygwin shows the right content:
c:\Tools\cygwin>bin\bash -c "/bin/ls -l | /bin/head -5"
total 313
-rw-r--r-- 1 robert.panzer root 53342 Oct 10 13:24 Cygwin-Terminal.ico
-rwxr-xr-x 1 robert.panzer root 63 Oct 10 13:24 Cygwin.bat
-rw-r--r-- 1 robert.panzer root 157097 Oct 10 13:24 Cygwin.ico
drwxr-xr-x+ 1 robert.panzer Domain Users 0 Oct 10 13:22 bin
I guess you upgraded from the Cygwin 1.5.x series (using Bash 3.x) to the 1.7.x series (using Bash 4.x).
There is nothing surprising in Cygwin's behaviour. What surprises me is that it used to do something different.
Your Cygwin uses your c:/Tools/cygwin as its Unix root directory /. Everything inside this is part of the Unix filesystem, so the drive letter stuff is omitted. Everything else outside c:/Tools/cygwin is available under the /cygdrive/<driveletter> mount points.
And now to the /usr/bin stuff. Cygwin's /bin folder is sort of a hardlink to /usr/bin. All the executables are in /usr/bin.
I want to run a shell script on startup
by google ,I found that I could add shell in rc.common
so I added the code below at the end of rc.common
is it a permission problem?
## rc.common test ##
touch ~/test.txt
reboot,there is no test.txt in my user fold
when I test it in terminal manualy ,it's ok
ls -l /etc/rc.common
-rw-r--r-- 1 guirong wheel 1737 3 30 22:36 /etc/rc.common
where is the problem? my system verison is 10.7.3
is it not ran by default in os x?
Just as an added bit of information about what was happening; /etc/rc.common runs as root, so when you were touching the file at ~/test.txt it would have been ending up in /var/root (the root user's home directory)
If you want the script to be run only for the current user, you should use ~/.bashrc instead
Later edit: I misread your question. If you want something to run at startup, you should look into launchd here
so, I just downloaded the latest Version of chipmunk, and when I run the iphonestatic.command from finder I get the following output in my Command Line
Last login: Wed Oct 26 22:15:59 on ttys001
PS1:~ Thermo$ /Users/Thermo/Desktop/Programs\ software/Software/iphonestatic.command ; exit;
usage: dirname path
Build settings from command line:
SDKROOT = iphoneos4.3
xcodebuild: error: 'Chipmunk6.xcodeproj' does not exist.
logout
I can't get the script to build the proper files, and have been trying to figure this out for a while,
thanks for any help
Aha! After a stroke of luck I discovered that you could cause that bug by having a space in your path somewhere.
The first line of the script does this to set the working directory to the parent directory of the script when running it from the finder:
cd `dirname $0`
It barfs when you have a space in the path somewhere. Not exactly certain how to fix it... The workaround is easy enough though, just make sure you put it somewhere it won't have a space.
edit: Looks like it just needs multiple sets of parens:
cd "`dirname "$0"`"