jhm
jhm

Reputation: 4539

Android Studio release build not zipaligning

I'm having trouble uploading my .apk to Google Play Store. I've previously been able to upload multiple different builds up to last week, but today I get the error that I should zipalign my file first.

EDIT: Normally, I was able to generate signed and zipaligned .apk's that the AppStore accepted by just using Android Studios built-in "Generate Signed APK" wizard. This did not work today, and led to the following:

I've tried the following:

I'm out of suggestions, and hoping someone can help? :-) Thanks

Upvotes: 4

Views: 1047

Answers (2)

jhm
jhm

Reputation: 4539

Finally, eureka!

I randomly stumbled upon this line in my root build.gradle:

classpath 'com.android.tools.build:gradle:2.2.0-alpha3'

Android Studio 2.2 preview 3 requires this gradle build tool upgrade, and I had just pressed "sure, go ahead" as always. I got curious, and tried to change it back to what had worked last,

classpath 'com.android.tools.build:gradle:2.2.0-alpha2'

and built the project in Android Studio preview 2 instead - and voila, it worked! It seems there is a bug with the alpha3 build.

I hope this helps someone. I know I'm a happy friday-camper, that's for sure! :-)

Note to self: Don't rely on canary-builds for production apps in the future, no matter how much my friends and collegues push.

Upvotes: 4

Eenvincible
Eenvincible

Reputation: 5626

Here are the things that I faced a few days ago: Try them one at a time:

  • After downloading Android Studio 2.2 Preview 2 - which was released during the IO conference, I ran my code successfully until when time came to release a newer version of the apk to the playstore. That was when hell broke loose!
  • I searched all over but I got nothing. So, someone suggested the following approach: After generating your signed apk, unzip it and delete META-INF folder then re-package it and manually sign it through the terminal. Packaging a file into .apk format is simple: just use a zip extension then rename the extension.
  • Although that seemed like it could have worked for me, it didn't. It worked for others though.
  • Finally, I realized that it was caused by a bug in the latest Android Studio Preview 2.
  • Thankfully, I still had my stable 2.1 version which I opened, loaded my project and Boom! It worked like I expected it to.

So, please try the last option, clean up your project first then try again. I know how frustrating this can be. Good luck!

Upvotes: 3

Related Questions