上传到Google Play时,android apk不对齐 [英] android apk not zip aligned when uploading to Google Play

查看:194
本文介绍了上传到Google Play时,android apk不对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我已经尝试通过终端手动对齐APK,并在<$ zipAlignEnabled true c $ c> build.gradle 移动和磨损文件。我将在下面发布完整的gradle文件



另外我最近注意到,当我点击生成已签名的apk (一个名为mobile- release.apk和一个名为wear-release.apk)它从来没有这样做过。这可能是为什么?



任何帮助? build.gradle(Module:mobile)

  apply plugin:'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion24-rc4

defaultConfig {
applicationIdcom.vivekvinodh.example
minSdkVersion 21
targetSdkVersion 23
versionCode 11
versionName0.7
//启用multidex支持。
multiDexEnabled true
}
signingConfigs {
release {
storeFile file('***********')
storePassword ************
keyAlias******
keyPassword************
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
signedConfig signingConfigs.release
zipAlignEnabled true



$ dependencies {
compile fileTree(include:['* .jar' ],dir:'libs')
wearApp项目(':wear')
编译'com.android.support:appcompat-v7:23.4.0'
编译'com.google。 android.gms:play-services:9.0.2'
compile'c​​om.google.android.gms:play-services-ads:9.0.2'
compile'net.steamcrafted:materialiconlib:1.0。 9''
编译'com.android.support:multidex:1.0.1'
compile'c​​om.android.support:support-v4:23.4.0'
...
}

build.gradle(模块:穿着)

  apply插件:'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion24-rc4

defaultConfig {
applicationIdcom.vivekvinodh.example
minSdkVersion 21
targetSdkVersion 23
versionCode 11
versionName0.7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
zipAlignEnabled true
}
}
}

依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
编译'com.google.android.support :wearable:1.4.0'
compile'c​​om.google.android.gms:play-services-wearable:9.0.2'
compile'c​​om.and roid.support:palette-v7:23.4.0'
compile'c​​om.ustwo.android:clockwise-wearable:1.0.1'
...
}
code>


解决方案

这是对我的帮助:

我在这里下载了稳定的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插件的版本即可完成工作。


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

解决方案

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.

这篇关于上传到Google Play时,android apk不对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆