You uploaded an APK that is not zip aligned error
Asked Answered
D

7

31

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 .

Dioscuri answered 27/3, 2014 at 8:24 Comment(0)
D
31

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)

Denadenae answered 27/3, 2014 at 8:35 Comment(10)
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 "Dioscuri
If apk is not signed, you should sign it before zipalign. For more details developer.android.com/tools/publishing/app-signing.html#signappDenadenae
I have did that through Android Studio => generate signed apkDioscuri
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 keystoreDenadenae
Just tried to use apkprotect, it removed certificate from META-INF, so I signed and zipaligned apk and it worked!Denadenae
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURKEYSTORE unsigned.apk alias_nameDenadenae
jarsigner is located inside java JDK_HOME/binDenadenae
Interesting, I can't disable zip align in my case. Event if I'm using gradlew assembleRelease directly.Appropriation
what is infile.apk and outfile.apk in this case? ThanksRiesman
@Gediminas infile.apk is the original apk which should be zipaligned and outfile.apk is the final zipaligned apk.Denadenae
L
20

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

Lehet answered 15/9, 2014 at 22:0 Comment(0)
T
7

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.

Talesman answered 28/4, 2015 at 19:53 Comment(2)
I was using the wrong apk.... I used one in "<project directory>\\build\outputs\apk" instead the one in the base of the project directoryTail
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 itCarburize
I
7

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.

Intumescence answered 29/10, 2019 at 23:50 Comment(1)
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.Whelp
C
6

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
Chadwick answered 9/1, 2017 at 15:29 Comment(0)
G
1

I was using Cordova and the command line getting this error. I opened the project in Android Studio and used Android Studio to build the signed apk and the error went away.

Giro answered 14/10, 2016 at 15:15 Comment(0)
A
0

When using the Cordova node.js CLI without going through Android Studio, it is necessary to update the PATH environmental variable to include the android build tools:

%ANDROID_HOME%\build-tools\29.0.2

Obviously the version number will change over time. Remember to close any CLI windows and re-open them to recognize the newly added path.

Anagram answered 29/10, 2019 at 2:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.