错误:将字节码转换为dex时出错:多个dex文件定义 [英] Error:Error converting bytecode to dex: Multiple dex files define

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

问题描述

我遇到了这个问题,您能帮我吗?

i got this issues can u help me:

Error:Error converting bytecode to dex:

原因:com.android.dex.DexException:多个dex文件定义了Lcom/google/android/gms/auth/api/signin/internal/zzf; ...

Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/internal/zzf; ...

失败:构建失败,并出现异常.

FAILURE: Build failed with an exception.

  • 出了什么问题: 任务':app:transformClassesWithDexForDebug'的执行失败.
  • What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:执行时出错具有主类com.android.dx.command.Main且带有参数{--dex --num-threads = 4 --output D:\ Projectos \ Chat_Final \ app \ build \ intermediates \ transforms \ dex \ debug \ folders的Java进程\ 1000 \ 1f \ main D:\ Projectos \ Chat_Final \ app \ build \ intermediates \ pre-dexed \ debug \ classes_9fd79174a0a6dc23209652a8a58b3e02e9146491.jar D:\ Projectos \ Chat_Final \ app \ build \ intermediates \ pre-dexed \ debug \ bolts-bolts -1.4.0_7536087ced7b51cacc52bdfc4ca05ab61d61e0c3.jar D:\ Projectos \ Chat_Final \ app \ build \ intermediates \ pre-dexed \ debug \ jackson-databind-2.2.2_c79be971c56bd1cdc38488184cf71a5146_帽子\ inters \ build \ pres \ apps \ dex \ apps \ dex \ apps \ dex \ apps \ dex_app \ dex \ debug \ classes_3b9a81b892f55e63da37657bf33b2ce2fe9ca8b0.jar

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --output D:\Projectos\Chat_Final\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\classes_9fd79174a0a6dc23209652a8a58b3e02e9146491.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\bolts-applinks-1.4.0_7536087ced7b51cacc52bdfc4ca05ab61d61e0c3.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\jackson-databind-2.2.2_c79be971c56bd1cdc38488184cf71a5146b761ff.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\classes_3b9a81b892f55e63da37657bf33b2ce2fe9ca8b0.jar

我的build.glade

my build.glade

    packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}

}

/*包装选项{ 排除"META-INF/许可" //如果您使用的是Firebase,请在行下方包含 //排除"META-INF/LICENSE-FIREBASE.txt" 排除"META-INF/NOTICE" } */

/* packagingOptions { exclude 'META-INF/LICENSE' //include below line if you are using firebase //exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' }*/

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])


    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'


    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    //compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'


    compile 'com.android.support:appcompat-v7:25.0.1'

    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.firebase:firebase-database:10.2.6'
    compile 'com.google.firebase:firebase-storage:10.2.6'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.firebaseui:firebase-ui-database:0.6.0'
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'


    compile 'com.firebaseui:firebase-ui-auth:0.6.0'
    //compile 'com.android.support:multidex:1.0.0'

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'


    compile 'com.squareup.okhttp3:okhttp:3.6.0'

    //Notification

    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'




    compile 'com.google.android.gms:play-services-gcm:10.2.6'

    compile 'com.google.android.gms:play-services-location:10.2.6'



}

应用插件:"com.google.gms.google-services"

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

推荐答案

如果您的 minSdkVersion 设置为 21或更高版本,则只需设置build.gradle文件中> multiDexEnabled 设置为 true ,如下所示:

If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your app-level build.gradle file, as shown here:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

但是,如果您的 minSdkVersion 设置为 20或更低,则必须使用multidex支持库,如下所示:

However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

修改应用程序级别的build.gradle文件以启用multidex,并将multidex库添加为依赖项,如下所示:

Modify the app-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

创建这样的Application类:

Create an Application class like this:

public class MyApplication extends MultiDexApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

在清单中添加此应用程序类.

Add this application class in Manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your package name">
    <application
        android:name=".MyApplication" >
        ...
    </application>
</manifest>

您还可以检查此链接:

https://developer.android.com/studio/build/multidex.html

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

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