上传到 Google Play 时,android apk 未与 zip 对齐

Posted

技术标签:

【中文标题】上传到 Google Play 时,android apk 未与 zip 对齐【英文标题】:android apk not zip aligned when uploading to Google Play 【发布时间】:2016-10-13 12:25:38 【问题描述】:

在将我的 APK 上传到 Google Play 时,我遇到了以前从未遇到过的错误。该窗口通知我,我正在上传一个未与 zip 对齐的 APK。但是,当我上传以前版本的 APK 时,这些错误从未发生过。

我已经尝试通过终端手动压缩对齐 APK 并在 build.gradle 文件中写入 zipAlignEnabled true 以用于移动和穿戴。我将在下面发布完整的 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'
    ...

【问题讨论】:

在您的build.gradle 文件中minifyEnabled false 将其更改为minifyEnabled true 这也将帮助你[看到这个](***.com/a/38055015/1978475) 【参考方案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 插件的版本即可。

【讨论】:

更多的是解决方法而不是解决方案,我希望 gradle 插件的下一个测试版最终能解决它。无论如何,非常感谢agamov,我终于能够发布一个版本了!干杯!

以上是关于上传到 Google Play 时,android apk 未与 zip 对齐的主要内容,如果未能解决你的问题,请参考以下文章

无法通过 fastlane 使用 Google Play 应用签名将 android 包上传到 Google Play

通过将 proguard 规则映射文件上传到 google play 控制台去混淆生产 Android 错误

如何将超过 150MB 的 Android App Bundle (.aab) 上传到 Google Play

将Android应用程序(在Delphi FireMonkey中开发)部署到Google Play商店

提交到 Google Play 时出错 - Android 应用程序 [关闭]

您的 Android App Bundle 使用错误的密钥进行签名。 (首次在 google play store 上传应用时)