Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android apk not zip aligned when uploading to Google Play

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'
    ...
}
like image 767
Vivek Vinodh Avatar asked Jun 13 '16 07:06

Vivek Vinodh


1 Answers

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.

like image 136
agamov Avatar answered Nov 06 '22 23:11

agamov