android apk not zip aligned when uploading to Google Play
Asked Answered
W

1

7

when uploading my APK to Google Play I'm getting an error I've never encountered before. The window informs me that I'm uploading an APK that is not zip aligned. However when I've uploaded previous versions of the APK these errors never occurred.

I've already tried manually zip aligning the APK manually through the terminal and writing zipAlignEnabled true in the build.gradle files for mobile and wear. I'll post the full gradle files below

Also I recently noticed that Android Studio is generating two signed apk's when I click generate signed apk (one named mobile-release.apk and one named wear-release.apk) It's never done this before. Could that be a reason why?

Any help?

build.gradle (Module: mobile)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24-rc4"

defaultConfig {
    applicationId "com.vivekvinodh.example"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 11
    versionName "0.7"
    // Enabling multidex support.
    multiDexEnabled true
}
signingConfigs {
    release {
        storeFile file('***********')
        storePassword "************"
        keyAlias "******"
        keyPassword "************"
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
        zipAlignEnabled true
    }
}
}

dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     wearApp project(':wear')
     compile 'com.android.support:appcompat-v7:23.4.0'
     compile 'com.google.android.gms:play-services:9.0.2'
     compile 'com.google.android.gms:play-services-ads:9.0.2'
     compile 'net.steamcrafted:materialiconlib:1.0.9''
     compile 'com.android.support:multidex:1.0.1'
     compile 'com.android.support:support-v4:23.4.0'
     ...
 }

build.gradle (Module: wear)

apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion "24-rc4"

defaultConfig {
    applicationId "com.vivekvinodh.example"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 11
    versionName "0.7"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.4.0'
    compile 'com.google.android.gms:play-services-wearable:9.0.2'
    compile 'com.android.support:palette-v7:23.4.0'
    compile 'com.ustwo.android:clockwise-wearable:1.0.1'
    ...
}
Warr answered 13/6, 2016 at 7:13 Comment(2)
in your build.gradle file minifyEnabled false change it to minifyEnabled trueDemobilize
This will also helps you [see this ](https://mcmap.net/q/340666/-android-studio-how-to-zipalign-apk)Radiothorium
D
12

This is what helped me:

I downloaded stable Android Studio 2.1 here: https://developer.android.com/studio/index.html Then in build.gradle I changed gradle plugin version from

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

to

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

Rebuild, sign, upload - no more zipalign errors.

UPDATE: Just downgrading the version of Gradle plugin should do the work.

Drawstring answered 13/6, 2016 at 10:2 Comment(1)
More a workaround than a solution, I hope the next beta of gradle plugin will finally solved it. Anyway thank you very much agamov, I was finally able to publish a build! Cheers!Haimes

© 2022 - 2024 — McMap. All rights reserved.