添加firebase后获取本机android多索引错误

添加firebase后获取本机android多索引错误,android,firebase,Android,Firebase,Logcat输出: Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzc; Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForStagingDebug'. com.a

Logcat输出:

Error:Error converting bytecode to dex:
     Cause: com.android.dex.DexException: Multiple dex files define 
     Lcom/google/firebase/iid/zzc;

Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForStagingDebug'.

 com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzc;
这是我的build.Gradle文件:

apply plugin: 'com.android.application'
buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}

apply plugin: 'io.fabric'
android {

}

useLibrary 'org.apache.http.legacy'

compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
    applicationId "app.test.test”
    minSdkVersion 15
    targetSdkVersion 23

    versionCode 101
    versionName “1.2.5”

    multiDexEnabled true

    resConfigs "en"
 }

 dataBinding {
    enabled true
 }

 sourceSets {
    main {
        manifest.srcFile 'src/main/AndroidManifest.xml'
        res.srcDirs = ['src/main/res']
        assets.srcDirs = ['src/main/assets']
    }
    main.java.srcDirs += 'src/main/java/'
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
 }

  android {
    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries true
        maxProcessCount 8
    }

    aaptOptions {
        cruncherEnabled false
    }
}

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.app_release
    }

    debug {
        debuggable true
        signingConfig signingConfigs.app_release
    }
}

productFlavors {
    production {
        minSdkVersion 15
        applicationId "app.test.test"
        resValue "string", "app_name", "test"
        resValue "string", "content_authority", "app.test.test.sync.StubContentProvider"
        resValue "string", "account_type", "test.com"
        dimension "mode"
    }

configurations {
    all*.exclude module: 'gson'
}
}

repositories {
def androidHome = System.getenv("ANDROID_HOME")
mavenCentral()

maven { url "$androidHome/extras/android/m2repository/" }

maven { url "https://repo.commonsware.com.s3.amazonaws.com" }

maven { url "https://raw.githubusercontent.com/layerhq/releases-android/master/releases/" }

maven { url 'https://maven.fabric.io/public' }

maven { url 'https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk' }

maven { url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/" }

maven { url "https://jitpack.io" }

maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

maven {
    url 'https://maven.google.com'
}
}

dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs')
annotationProcessor files('libs/butterknife-6.1.0.jar')
implementation files('libs/butterknife-6.1.0.jar')
implementation files('libs/retrofit-1.9.0.jar')

// segment - analyti

//crashlytics
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
    transitive = true
}

implementation 'com.android.support:appcompat-v7:25.2.0'
implementation 'com.android.support:recyclerview-v7:25.2.0'
implementation 'com.android.support:cardview-v7:25.2.0'
implementation 'com.android.support:support-v4:25.2.0'
implementation 'com.android.support:design:25.2.0'
//multidex lib
implementation 'com.android.support:multidex:1.0.1'
implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.felipecsl:gifimageview:1.1.0'
implementation 'com.squareup.okhttp:okhttp:2.3.0'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
implementation 'net.the4thdimension:poly-picker:1.0.11'
implementation 'com.navercorp.pulltorefresh:library:3.2.3@aar'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.getbase:floatingactionbutton:1.10.0'
//play service
implementation ('com.google.firebase:firebase-core:10.2.4'){
    exclude group: 'com.google.android.gms'
}
implementation ('com.google.firebase:firebase-messaging:10.2.4'){
    exclude group: 'com.google.android.gms'
}
implementation ('com.google.firebase:firebase-appindexing:10.2.4'){
    exclude group: 'com.google.android.gms'
}
implementation ('com.google.firebase:firebase-crash:10.2.4'){
    exclude group: 'com.google.android.gms'
}

implementation 'com.google.android.gms:play-services-plus:10.2.4'
implementation 'com.google.android.gms:play-services-location:10.2.4'
implementation 'com.google.android.gms:play-services-gcm:10.2.4'
implementation 'com.google.android.gms:play-services-auth:10.2.4'
implementation 'com.google.android.gms:play-services-
analytics:10.2.4'

implementation project(':PlaceAutoComplete')
implementation files('libs/gson-2.8.0.jar')
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
}
apply plugin: "com.google.gms.google-services"
我知道有很多库,但它工作正常,突然它抛出了一个多索引错误。我已经更新了我的Sdk平台和Sdk工具,但仍然不工作

我知道有很多库,但它工作正常,突然它抛出了一个多索引错误。我已经更新了我的Sdk平台和Sdk工具,但仍然不工作


我知道有很多库,但它工作正常,突然它抛出了一个多索引错误。我已经更新了我的Sdk平台和Sdk工具,但仍然不工作

如下配置多索引:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
为低于API 21的android版本扩展这样的应用程序类:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
现在在清单文件中添加应用程序类:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

如下配置多索引:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
为低于API 21的android版本扩展这样的应用程序类:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
现在在清单文件中添加应用程序类:

android {    
    defaultConfig {
        // Enable multidex support for android versions grater than API 21
        multiDexEnabled true
    }  
}

dependencies {
    // Enable multidex support for android versions lower than API 21
    compile 'com.android.support:multidex:1.0.0'
}
public class MultiDexApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
<application
    android:name=".MultiDexApp" <!-- enable application class -->
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

检查此ans它可能会帮助您我的朋友仍然无法工作检查此ans它可能会帮助您我的朋友仍然无法工作您正在运行此应用程序的android版本相同的问题。原因:com.android.dex.dex异常:多个dex文件定义Lcom/google/firebase/iid/zzcminSdkVersion 15 targetSdkVersion23@user3606902禁用即时运行。而不是运行与问题共享您的gradle应用程序文件在哪个android版本中运行此应用程序相同的问题。原因:com.android.dex.dex异常:多个dex文件定义Lcom/google/firebase/iid/zzcminSdkVersion 15 targetSdkVersion23@user3606902禁用即时运行。而不是用问题分享你的gradle应用程序文件