android apk 在上传到 Google 时未对齐

android apk not zip aligned when uploading to Google Play

将我的 APK 上传到 Google Play 时,我遇到了以前从未遇到过的错误。 window 告诉我我正在上传一个没有压缩对齐的 APK。但是,当我上传以前版本的 APK 时,这些错误从未发生过。

我已经尝试通过终端手动压缩对齐 APK,并在移动和穿戴设备的 build.gradle 文件中写入 zipAlignEnabled true。我将 post 完整的 gradle 文件放在下面

我最近还注意到,当我单击生成签名的 apk 时,Android Studio 正在生成两个签名的 apk(一个名为 mobile-release.apk 和一个名为 wear-release.apk) 以前从来没有这样做过。这可能是原因吗?

有什么帮助吗?

build.gradle(模块:移动)

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(模块:穿)

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

这对我有帮助:

我在这里下载了稳定版 Android Studio 2.1:https://developer.android.com/studio/index.html 然后在 build.gradle 中,我将插件版本从

更改为 gradle

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

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

重建、签名、上传 - 不再有 zipalign 错误。

更新: 只需降级 Gradle 插件的版本即可。