运行我的Android代码时出现这些错误

时间:2018-05-03 18:49:16

标签: android firebase build.gradle google-cloud-firestore

  

错误:将字节码转换为dex时出错:   原因:com.android.dex.DexException:多个dex文件定义Lcom / google / android / gms / internal / measurement / zzabn;   :app:transformClassesWithDexForDebug FAILED   错误:任务':app:transformClassesWithDexForDebug'执行失败。   com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process。 internal.ExecException:进程' C:\ Program Files \ Java \ jdk1.8.0_91 \ bin \ java.exe''完成非零退出值2

这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.3"


    defaultConfig {

        applicationId "quotspot.inext.quotspot"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}



dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.google.firebase:firebase-core:15.0.0'
    compile 'com.google.firebase:firebase-messaging:15.0.0'
    compile 'com.google.firebase:firebase-storage:15.0.0'
    compile 'com.firebaseui:firebase-ui:0.4.2'
    compile 'com.google.firebase:firebase-database:15.0.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
    compile 'com.google.firebase:firebase-auth:15.0.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.google.firebase:firebase-firestore:15.0.0'
    compile 'com.larswerkman:HoloColorPicker:1.5'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.android.support:multidex:1.0.1'

}

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

3 个答案:

答案 0 :(得分:2)

Firebase于昨天(5/2)更新,导致您导入的各种firebase依赖关系不同步。

解决方案是将它们更新为最新版本,您可以通过以下方式找到:

  1. 转到Firebase release notes获取最新版本列表,或
  2. 在Android Studio中打开 build.gradle 文件,查看哪些Firebase依赖项已突出显示,将光标放在每个依赖项上方以查看最新版本号

答案 1 :(得分:0)

尝试在

中添加multiDexEnabled true
android {
    compileSdkVersion 27
    defaultConfig {
          applicationId "quotspot.inext.quotspot"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"

        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }

答案 2 :(得分:0)

要解决此问题,请更改以下所有代码行:

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.google.firebase:firebase-core:15.0.0'
    compile 'com.google.firebase:firebase-messaging:15.0.0'
    compile 'com.google.firebase:firebase-storage:15.0.0'
    compile 'com.firebaseui:firebase-ui:0.4.2'
    compile 'com.google.firebase:firebase-database:15.0.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
    compile 'com.google.firebase:firebase-auth:15.0.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.google.firebase:firebase-firestore:15.0.0'
    compile 'com.larswerkman:HoloColorPicker:1.5'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.android.support:multidex:1.0.1'

}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.aurelhubert:ahbottomnavigation:0.1.3'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.google.firebase:firebase-core:15.0.2'
    compile 'com.google.firebase:firebase-messaging:15.0.2'
    compile 'com.google.firebase:firebase-storage:15.0.2'
    compile 'com.firebaseui:firebase-ui:3.3.1'
    compile 'com.google.firebase:firebase-database:15.0.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.0'
    compile 'com.google.firebase:firebase-auth:15.1.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.google.firebase:firebase-firestore:16.0.0'
    compile 'com.larswerkman:HoloColorPicker:1.5'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.android.support:multidex:1.0.1'

}

有关更多信息,请参阅此linkthis