错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom/google/android/gms/common/api/zza;

错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom/google/android/gms/common/api/zza;

问题描述:

我有此错误:

错误:将字节码转换为dex时出错:原因: com.android.dex.DexException:多个dex文件定义 Lcom/google/android/gms/common/api/zza;

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;

我没有解决方法,请帮忙.

I am not getting how to solve this, please help.

我不知道是否要包含一些lib或什么

I don't know whether to include some lib or what

当您在应用程序build.gradle中有重复的依赖项条目时,通常会出现Multiple dex files define的问题.在这种情况下,您有重复的Firebase依赖项.

The problems of Multiple dex files define usually arise when you have duplicate dependency entry in your app build.gradle. In this case, you have a duplicate Firebase dependencies.

您需要使用相同版本的9.0.29.6.1:

You need to use the same version either 9.0.2 or 9.6.1:

compile 'com.google.firebase:firebase-auth:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.2'

compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.google.firebase:firebase-database:9.6.1'

请注意 ,如果您使用某些支持库版本(例如24.0.0),则Firebase可能会出现兼容性问题.您需要使用最新的支持库或找到兼容的Firebase版本.进一步了解编译com.android.support时出现android错误. :support-v4:24.0.0

Please be aware that if you use some support library version like 24.0.0 there is a chance for compatibility issue with firebase. You need to use the latest of support library or find the compatible firebase version. Read more at android error while compiling com.android.support:support-v4:24.0.0