错误:将字节码转换为dex时出错: 原因:com.android.dex.DexException:多个dex文件定义Lcom / google / android / gms / internal / zzbqy;
这个错误出现在我的Android聊天应用程序中,我在这里找到了几个答案,但它无法解决我的问题。我正在为我的项目使用Firebase,我已经成功完成了对我的用户的身份验证,并希望在实时数据库中应用他们的照片和用户名,但此错误阻止了进一步的开发。我错误的是这个错误来了吗?
的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.john.androidchat"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.synnapps:carouselview:0.0.10'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:1)
在您的应用中启用Multidex并增加堆大小。
例如build.gradle
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
依赖项{
compile 'com.android.support:multidex:1.0.1'
}
在Manifest
中的Application标记内写下以下代码机器人:名称= “android.support.multidex.MultiDexApplication”
答案 1 :(得分:1)
确保首先列出您的firebase依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.android.support:appcompat-v7:26.0.0+'
compile 'com.android.support:design:26.0.0+'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.7.0'
}
apply plugin: 'com.google.gms.google-services'
答案 2 :(得分:1)
对于那些具有匹配的依赖版本且仍然收到此错误的人:
Firebase Android SDK现在具有独立的版本号,允许 更频繁,更灵活的更新。
将所有Firebase依赖关系更新为最新版本(截至2018年5月2日):
Firebase Core com.google.firebase:firebase-core:15.0.2
Ads com.google.firebase:firebase-ads:15.0.0
Analytics com.google.firebase:firebase-analytics:15.0.2
App Indexing com.google.firebase:firebase-appindexing:15.0.0
Authentication com.google.firebase:firebase-auth:15.1.0
Cloud Firestore com.google.firebase:firebase-firestore:16.0.0
Cloud Functions com.google.firebase:firebase-functions:15.0.0
Cloud Messaging com.google.firebase:firebase-messaging:15.0.2
Cloud Storage com.google.firebase:firebase-storage:15.0.2
Crash Reporting com.google.firebase:firebase-crash:15.0.2
Crashlytics com.crashlytics.sdk.android:crashlytics:2.9.1
Invites com.google.firebase:firebase-invites:15.0.2
Performance Monitoring com.google.firebase:firebase-perf:15.1.0
Realtime Database com.google.firebase:firebase-database:15.0.0
Remote Config com.google.firebase:firebase-config:15.0.2
发行说明: https://firebase.google.com/support/release-notes/android