我的 Android Studio 项目的 APK 未对齐(上传失败)

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

我一直无法上传从 Android Studio 生成的签名 APK 文件,尽管我已经尝试了许多不同的解决方案来解决它。

这是我上传时得到的:

我也看到了一些编写 zipalign 命令的解决方案,但是在 mac 的终端中输入命令时,我总是收到 "command not found" 消息。

这是我在项目内的build.gradle(模块:app)文件中的配置:

        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')
    }

我找到了这个解决方案,它解决了我的问题:

全部都是关于将 build.gradle 文件中的 1 行更改为:

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