zipalign verification failed resources.arsc BAD-1

时光毁灭记忆、已成空白 提交于 2019-12-04 07:42:46
Vrajesh

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

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..

Try below suggestion

buildTypes {
        release {
        }
        debug{
            debuggable false
        }
    }

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!