【问题标题】:Multiple dex files define Lcom/google/android/gms/internal/zzbqy;多个dex文件定义Lcom/google/android/gms/internal/zzbqy;
【发布时间】:2017-08-14 03:02:57
【问题描述】:

错误:将字节码转换为 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'

【问题讨论】:

  • 显示build.gradle
  • 应用插件:'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' } } }
  • 编译 'com.android.support:appcompat-v7:25.1.0' 编译 'com.android.support:design:25.1.0' 编译 'com.github.bumptech.glide:glide: 3.7.0'编译'de.hdodenhof:circleimageview:2.1.0'编译'com.google.code.gson:gson:2.8.0'编译'com.synnapps:carouselview:0.0.10'编译'com.google。 firebase:firebase-auth:10.2.0' 编译 'com.google.firebase:firebase-database:10.2.0' 编译 'com.android.support.constraint:constraint-layout:1.0.1' 编译 'com.google. firebase:firebase-storage:10.0.1' testCompile 'junit:junit:4.12'
  • 添加这个问题部分。
  • 设置firebase-storage:10.2.0

标签: android firebase firebase-realtime-database


【解决方案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

【讨论】:

    【解决方案2】:

    确保首先列出您的 firebase 依赖项:

    app/build.gradle

    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'
    

    【讨论】:

      【解决方案3】:

      在您的应用中启用 Multidex 并增加堆大小。

      例如 build.gradle

      安卓{

      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:name="android.support.multidex.MultiDexApplication"

      【讨论】:

      • multiDexEnabled true 可以接受,但为什么要降级?
      • 不要降级版本,我刚刚发布了示例代码结构以便更好地理解。
      • 没有降级版本我收到以下消息,请帮助我。 SocketException:无法获取 OAuth2 访问令牌。:连接重置
      猜你喜欢
      • 2018-07-01
      • 1970-01-01
      • 2018-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-15
      相关资源
      最近更新 更多