You uploaded an APK that is not zip aligned error

54,753

Solution 1

You can run zipalign manually in command line:

zipalign [-f] [-v] <alignment> infile.apk outfile.apk

Note that zipalign is located inside ${sdk.dir}\tools

For more details visit zipalign


[Update]

Also, If you need to sign it you can run:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURKEYSTORE unsigned.apk alias_name

(jarsigner is located inside java JDK_HOME/bin)

Solution 2

I got the same "You uploaded an APK that is not zip aligned... blah, blah" error when by mistake I tried to upload a DEBUG version of my .apk file to Google Play. It's a bit misleading error because the real problem is that you cannot distribute a debug version which additionally is not signed with your Google Android Developer key. (You can only upload an .apk compiled as release version, and it must be signed, which happens in the same step, at least if you're using Eclipse).

Make sure you distribute an .apk file which is your Signed Release version, as described here:

http://developer.android.com/tools/publishing/app-signing.html#releasecompile

Solution 3

This question and its answers are old; so we expect things to change. As of today, the zipalign tool is in the ANDROID_HOME directory under build-tools/[version]/ so my path is currently:

/android-sdk/build-tools/22.0.0/zipalign

Using the zipalign tool is not necessarily the answer here though, what you actually need to do is sign your apk.

Solution 4

Steps if using Xamarin for VS2017:

  1. Build project
  2. Right click and Archive project
  3. Use Ad Hoc distribution channel
  4. Sign your APK with your Signing Identity and Save As to produce an APK that is ZIP aligned.

Your APK can be uploaded to Google Play.

Solution 5

I was using Cordova, uploaded a signed APK but still got this error.

The ziptool is what helped me, it's located at ~AndroidSDK\build-tools\24.0.0\zipalign.exe

So for example :

"~\AndroidSDK\build-tools\24.0.0\zipalign.exe" -f -v 4 android-release-signed.apk android-release-signed-zipaligned.apk
Share:
54,753
Anas
Author by

Anas

Updated on January 20, 2020

Comments

  • Anas
    Anas over 4 years

    I have just finished and signed the apk through android studio, then I have did an apk protect through apkprotect.com when I am trying to upload the apk to play store I got this error " You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again. " if I upload the original apk I got no errors,

    I have tried to add zipalign true in the build.gradle but nothing happened I have tried also disable and enable proguard .

  • Anas
    Anas about 10 years
    I have just tried that with a protected apk, got this error from play store " You uploaded an unsigned APK. You need to create a signed APK "
  • Minas
    Minas about 10 years
    If apk is not signed, you should sign it before zipalign. For more details developer.android.com/tools/publishing/app-signing.html#sign‌​app
  • Anas
    Anas about 10 years
    I have did that through Android Studio => generate signed apk
  • Minas
    Minas about 10 years
    yes, but after you used apkprotect.com, apk became unsigned again. I never used apkprotect, but I think you didn't provided your keystore right? It can't sign you apk without keystore
  • Minas
    Minas about 10 years
    Just tried to use apkprotect, it removed certificate from META-INF, so I signed and zipaligned apk and it worked!
  • Minas
    Minas about 10 years
    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURKEYSTORE unsigned.apk alias_name
  • Minas
    Minas about 10 years
    jarsigner is located inside java JDK_HOME/bin
  • Randy
    Randy over 8 years
    I was using the wrong apk.... I used one in "<project directory>\\build\outputs\apk" instead the one in the base of the project directory
  • Kimi Chiu
    Kimi Chiu almost 6 years
    Interesting, I can't disable zip align in my case. Event if I'm using gradlew assembleRelease directly.
  • Kalpesh Popat
    Kalpesh Popat over 5 years
    this was my case too, i was trying to upload an archive generated by xamarin. then after reading this i created an adhoc publish and signed it
  • Gediminas
    Gediminas over 4 years
    what is infile.apk and outfile.apk in this case? Thanks
  • Minas
    Minas over 4 years
    @Gediminas infile.apk is the original apk which should be zipaligned and outfile.apk is the final zipaligned apk.
  • K0D4
    K0D4 over 2 years
    VS2019 update; Additionally, you have to uncheck [Fast Deployment] and build for [Release] when you try to do this. The Ad-hoc channel will also allow you to create a new signing keystore so you don't have to mess around with that if you don't have the appetite.