Search code examples
macosandroid-studioapkdeveloper-consolezipalign

My Android Studio Project's APK is not zip aligned (Upload Failure)


I keep on failing to upload the signed APK file generated from Android Studio, even though I have tried many different solutions to solve it.

This is what I get when uploading:

This image is what I get when uploading

I have also seen some solutions to write zipalign commands, but I always get the "command not found" message when entering the command in my mac's terminal.

And this is my configuration in the build.gradle (Module: app) file inside the project:

        apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.name.product"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        zipAlignEnabled true

    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
}
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.squareup.okhttp3:okhttp:3.0.1'
    compile(name:'material-search', ext:'aar')
    }

Solution

  • I found this solution and it solved my problem:

    https://stackoverflow.com/a/37842438/4846301

    It was all about changing 1 line in the build.gradle file to this:

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