可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
Perhaps the current directory is not in your path?
Try adding "./" before your command so
./zipalign -v 4 Project1.apk Project1-aligned.apk
回答2:
You will find the zipalign tool at /path/to/sdk/build-tools/zipalign NOT in the tools folder anymore.
回答3:
~/Library/Android/sdk/build-tools/xxxx/zipalign
Drag this to terminal or save this in your path. xxxx -> Version
回答4:
Zipalign is a command that located at $ANDROID_HOME/build-tools/{android-version}/.
Hope it helped.
回答5:
You can find correct path with this command:
find ~/Library/Android/sdk/build-tools -name "zipalign"
回答6:
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
回答7:
One-liner that adds zipalign to your profile and then reloads it
echo "export PATH=\$PATH:~/Library/Android/sdk/build-tools/23.0.1/" >> ~/.bash_profile && . ~/.bash_profile
Replace 23.0.1 with your version
$ ls -l ~/Library/Android/sdk/build-tools/ total 0 drwxr-xr-x 23.0.1
回答8:
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
回答9:
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.
回答10:
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
回答11:
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"
回答12:
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
回答13:
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.
回答14:
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
回答15:
%ANDROID_HOME%\\build-tools\\25.0.2\\zipalign -v 4 .\\platforms\\android\\build\\outputs\\apk\\input.apk .\\path\\ output.apk