zipalign verification failed resources.arsc BAD-1
Asked Answered
C

7

9

enter image description here

I try to upload my app to gplay but fail because my apk doesn't zipaligned. i try to zipalign but i got verification failed. really don't have idea, someone please tell me what to do. thanks in advance.

Counterespionage answered 27/6, 2016 at 6:40 Comment(2)
This will also helps you [see this ](https://mcmap.net/q/340666/-android-studio-how-to-zipalign-apk)Lichtenfeld
Don't include images of text--just copy and paste the text instead!Dodona
L
8

No need to manually, do this:

buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
                zipAlignEnabled true 
               //uncomment for automatically zip aligned by studio
            }
        }

build.gradle

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

to

classpath 'com.android.tools.build:gradle:2.1.2'

see my answer here

Lichtenfeld answered 1/7, 2016 at 17:19 Comment(0)
A
31

I found an easier way - just align from commandline.. TWICE! After aligning two times I was able to upload my apk.

Delete the OLD file and Rename the Second One and Align it Again..

Aerodrome answered 28/6, 2016 at 11:23 Comment(4)
It works. It's a bit depressing that those kind of workarounds are needed.Anapest
what ? really... After 2.3.x plugin release, they've removed option to disable zipalign so you no longer can do it manually from scratch. This created a problem with debug builds - calling zipalign fails with output above. Strangely, release builds are not affected. You saved my day - I was thinking about this issue for years and finally how a workaround.Cephalad
This is just a great catch. You saved me a lot of time. Thanx!Micrography
After hours of searching, this is the only thing that I worked for me.Epicurus
O
10

In case someone else has the same problem with gradle plugin '3.6.0' and later and because I spent several hours trying to track this down.

Gradle Plugin 3.6.0 is page aligning and packaging your native libraries uncompressed https://developer.android.com/studio/releases/gradle-plugin?hl=el#3-6-0

The fix is to disable the uncompressed packaging of your native libraries by adding

android:extractNativeLibs="true"

to your AndroidManifest.xml as an attribute on the application tag.

Obvious answered 29/5, 2020 at 16:56 Comment(1)
Worked for me as wellHeeler
L
8

No need to manually, do this:

buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
                zipAlignEnabled true 
               //uncomment for automatically zip aligned by studio
            }
        }

build.gradle

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

to

classpath 'com.android.tools.build:gradle:2.1.2'

see my answer here

Lichtenfeld answered 1/7, 2016 at 17:19 Comment(0)
H
4

Try below suggestion

buildTypes {
        release {
        }
        debug{
            debuggable false
        }
    }

Or set Attribute in Manifest android:debuggable="false" Generate build and run zipalign tool Verification Success.

Hinny answered 6/3, 2017 at 12:9 Comment(1)
strangely, this also works - do you have any idea why ?Cephalad
A
2

This issue will come when you are trying to zipalign and sign a debug apk.

That is not a good idea.

Instead use the command

./gradlew assembleRelease

to generate release unsigned apk. Then zipalign the output apk.

Or use the answer given by @Nilesh Senta

Armored answered 24/1, 2019 at 23:51 Comment(1)
This should be the answer!Donnydonnybrook
L
1

A little late to the party, but recently had the same issue when aligning the unsigned apk from command line. The zipalign command failed as I had the following code in the gradle file -

buildTypes {
    debug {
        debuggable true
    }
    release {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
    }
}

Zipalign was failing, but wasn't pointing to the fact that a release version cannot be marked as debuggable. Android Studio Build > Generate Signed Bundle / APK had no issues when the release version was marked as debuggable, so it must be overwriting some of the gradle configurations during the generation of the signed APK.

Hope this helps someone.

Laundryman answered 1/10, 2018 at 15:20 Comment(0)
M
-2

I had read that you needed to align the APK before signing; that if you sign first, then align, it would break the signature. That was false information. Sign first, then zipalign, then upload.

Maugre answered 22/4, 2020 at 17:32 Comment(1)
You absolutely can break your signature if you align after you sign it. Just because it works in your one instance doesn't mean it can't break the signature. The situation that causes it to break is a bit of an edge case, but if you ever get a random signature mismatch when installing the app it very likely would be because you are signing before aligning.Felder

© 2022 - 2024 — McMap. All rights reserved.