I am trying to get my Ionic app published. However, when trying to zipalign the apk with the following command
/Users/bertcarremans/Library/Android/sdk/build-tools/23.0.3/zipalign zipalign -v 4 android-release-unsigned.apk chartly.apk
I get the message below:
Zip alignment utility
Copyright (C) 2009 The Android Open Source Project
Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip
zipalign -c [-v] <align> infile.zip
<align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-c: check alignment only (does not modify file)
-f: overwrite existing outfile.zip
-p: page align stored shared object files
-v: verbose output
-z: recompress using Zopfli
How can I make the zipalign tool to work? Thanks!
I found the solution.
Copy the zipalign tool to the apk folder of your app. On my computer the zipalign tool was located in /Users/bertcarremans/Library/Android/23.0.3
Then run the command ./zipalign -v 4 android-release-unsigned.apk chartly.apk
There is no need to copy zipalign file anywhere, if it is installed through command line a symbolic link will be created and then you can run it from anywhere.
You are not using the right syntax of the zipalign tool. Please check again, you have written zipalign twice so you are passing zipalign as a parameter to zipalign command which is not correct.
Related
I've built a signed apk with cordova build --release android, should I zipalign it or did cordova already do all the job?
I know this is an old question, but figured I'd pitch the answer:
Cordova let's you hook on the "after_build" event, in which you can run a .bat file which will handle the zipalign.
Example (config.xml):
<hook type="after_build" src="zipalign_release.bat" />
The "src" is relative to project root (ie: same place config.xml resides).
My .bat:
if exist platforms\android\app\build\outputs\apk\release (
cd platforms\android\app\build\outputs\apk\release
zipalign -f -v 4 app-release.apk app-release-zipaligned.apk
) else (
echo Debug build.
)
no, you should zipalign it using the command prompt zipalign -v 4 app-release-unsigned.apk app-release.apk
I am getting the following error when I'm trying to install an APK with a higher version and same packageName over an existing one. The existing APK is a system app. It fails with the following error:
INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
However when I manually inspect the 2 apks their certificates seem to match. I used the following command:
unzip -p $package META-INF/CERT.RSA | keytool -printcert
Is there a different parameter which might be affecting this?
I am trying to zipalign an "input.apk" file on an Ubuntu 14.04 LTS system using the command line as I do not have access to the source code just yet. If I'm not mistaken I should be able to do this with the following command
zipalign [-f] [-v] 4 intput.apk output.apk
but I am getting the following output
zipalign: command not found
I have made sure that the zipalign file is in my ...sdk/tools directory which I had to copy over from my ...build-tools/android-4.4W folder because it was originally missing. When I input this line as suggested in another question
./zipalign [-f] [-v] 4 intput.apk output.apk
I get the following output
Zip alignment utility
Copyright (C) 2009 The Android Open Source Project
Usage: zipalign [-f] [-v] <align> infile.zip outfile.zip
zipalign -c [-v] <align> infile.zip
<align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-c: check alignment only (does not modify file)
-f: overwrite existing outfile.zip
-v: verbose output
Does this mean that I need a .zip file instead of my .apk to zipalign?
When a usage message contains an argument in brackets, the brackets mean that that argument is optional and can be left out of the final command; the brackets are not themselves part of the command syntax.
In your case, correct usage might look like:
./zipalign -v 4 intput.apk output.apk
In terminal,
cd /opt/android-sdk/build-tools/21.1.2
sudo ln -sf zipalign /usr/bin/
zipalign -v 4 platforms/android/ant-build/MainActivity-release-unsigned.apk platforms/android/ant-build/YOUR_APP.apk
Open terminal (CTRL + t)
cd YOUR_PATH/android-sdk-linux/build-tools/XX.X.X
sudo cp zipalign /usr/bin/
Open the folder where is located your apk in the terminal.
Execute zipalign -v 4 YOUR_APK.apk YOUR_APK.apk
I had the same issue. This is how i solved it, all you need is here.
1. Get zipalign path by getting sdk path on android studio. which is /Users/s****/Library/Android/sdk for me.
2. Paste the path on your terminal and cd to "build-tools/28.0.3/zipalign" now command will be/Users/s****/Library/Android/sdk/build-tools/28.0.3/zipalign
3. zip the apk on the same command line by adding -v 4 app-release-unsigned.apk my.apkto the command, now command will be
/Users/s****/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 app-release-unsigned.apk my.apk
4. Done.
I Wrote an android app.
I type zipalign myApp.apk on cmd at windows 7 and I get:
zipalign' is not recognized as an internal or external command operable program or batch file
What is the problem
zipalign.exe can be found in the build tools (my path in my PC is C:\Users\[user name]\Developer\adt-bundle-windows-x86_64-20131030\sdk\build-tools), in my builds 19.1.0 and 20.0.0 folders. If you can't find it, fire up Windows Explorer and search for zipalign.exe, likely in C:\, unless you have installed in another drive.
Copy zipalign.exe to the tools folder, same level as build-tools (in my case, it is C:\Users\[user name]\Developer\adt-bundle-windows-x86_64-20131030\sdk\tools). Once done, I could compile successfully.
Go to
Android/sdk/build-tools/VERSION/zipalign
copy the zipalign.exe into the current directory
and then run it.
Example:
Now to optimize the APK , run the following command
E:\app publish\J\JQuery Reference>zipalign -v 4 jquery-reference-unsigned.apk jq
ueryReference.apk
An example on how to run zipalign without adding the path variable from CMD prompt:
C:\Users\mywindowsusername\AppData\Local\Android\Sdk\build-tools\27.0.3\zipalign.exe -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
You should navigate to the directory wich has the zipalign executable in it.
Zipalign.exe is located in /path/to/android/sdk/build-tools/sdk-number
In command line:
Navigate to the location where zipalign.exe can be found
Run: zipalign -v -f 4 /full/path/to/apk/unaligned-apk.apk /full/path/to/new-aligned-apk.apk
you can also try this:
1.search for zipaligned in main search bar
2.copy it to current directory
3.run your commands without changing anything
4.it works! :)
Try this
zipalign -v 4 app-release-unsigned.apk xxx.apk
instead put infront of above command
./
while you run it in terminal
\platforms\android\app\build\outputs\apk\release>./zipalign -v 4 app-release-unsigned.apk xxx.apk
If you are using powershell like I was, exit and use standard windows command prompt and then it will execute :)
Copy zipalign exe file into the Android\Sdk\build-tools\ folder and add path in environment variables ...
im comming from ionic-doc, and thiew way works form me by adding this to PATH
/path/to/Android/sdk/build-tools/VERSION/zipalign
Is there a way to excecute the Eclipse command "Android Tools -> Rename Application Package" as a script from the shell?
I want to compile my Android application several times with different options (e.g. free and paid version) without doing some things manually.
It is important to do this automatically. All solutions like libraries won't help because several things have to be done by hand.
Yes, it is possible. You have to manually call aapt tool to package the compiled project, then call aapt again to add the classes, sign it with jarsigner and align it with zipalign. Normally, the Eclipse ADT plugin does the chain of build steps for you.
Example calls of the steps would be following.
Packaging the app with different package name:
aapt package -f -M ./AndroidManifest.xml -S res/ \
-I android.jar -F renamed_project.apk.unaligned \
--rename-manifest-package "com.example.some_new_package" -v
Then add the classes:
aapt add -f renamed_project.apk.unaligned classes.dex -v
Sign it:
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 \
-keystore "some_keystore_file" \
renamed_project.apk.unaligned "key_name"
Align it:
zipalign -v 4 renamed_project.apk.unaligned renamed_project.apk
Some more information can be found for example here.
Also you can do it more easily with Ant. Here you can find some more information.