生成签名的 APK 错误:将字节码转换为 dex 和 1 个时出错 [英] Generate Signed APK Error: Error converting bytecode to dex and 1 more

查看:28
本文介绍了生成签名的 APK 错误:将字节码转换为 dex 和 1 个时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我清理/重建我的项目甚至运行应用程序时,它不会返回任何错误.但是当我生成签名的 APK 时,它返回两个错误.

When I Clean/Rebuild my project or even run app, It doesn't return any errors. But when I generate signed APK, It returns two errors.

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzox;

还有这个

    Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzd.class

以下是来自 build.gradle 文件的代码.

Below is the code from build.gradle file.

apply plugin: 'com.android.application'


android {
    compileSdkVersion 24
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.wildlife.dbd"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 10
        versionName "2.2.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apply plugin: 'com.google.gms.google-services'

dependencies
{
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'

    // FB Ads
    compile 'com.facebook.android:audience-network-sdk:4.10.0'

    // Analytics
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
}

推荐答案

Facebook 受众网络也会引入游戏服务,因此您必须将其排除:

Facebook audience network will pull in play-services as well, so you'll have to exclude it:

我不太清楚 Facebook 的依赖项是什么,因此您的分析"行可能不够完整,无法让受众网络正常运行.您可能希望像这样添加整个播放服务:compile 'com.google.android.gms:play-services:9.2.1',然后删除分析.

I don't remember exactly what Facebook's dependencies are, so your 'analytics' line might not be complete enough for the audience network to run properly. You might want to add the entire play services like so: compile 'com.google.android.gms:play-services:9.2.1', and remove analytics.

或者,如果您能准确地看到 Facebook 需要哪些依赖项,您可以在此处获取正确的依赖项.

Or if you can see exactly which dependencies Facebook requires, you can grab the correct ones here.

compile ('com.facebook.android:audience-network-sdk:4.10.0') {
    exclude group: 'com.google.android.gms'
}

这篇关于生成签名的 APK 错误:将字节码转换为 dex 和 1 个时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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