2016-06-27 6 views
0

Ich bekomme den folgenden Fehler, wenn ich Fire Base Analytics in meinem Android Studio-Projekt hinzufügen: "Fehler: Fehler beim Konvertieren von Bytecode zu dex: Ursache: com.android.dex .DexException: Mehrere Dex-Dateien definieren Lcom/google/android/gms/measurement/AppMeasurementContentProvider; "Mehrere Dex-Datei Fehler beim Hinzufügen von Fire Base-Analysen in Android Studio

Ich bin wirklich dankbar, wenn mir jemand sagt, woher der zusätzliche AppMeasurementContentProvider kommt und den entsprechenden "exclude" -Befehl.

Hier ist meine build.gradle

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 
android { 
compileSdkVersion 21 
buildToolsVersion "22.0.1" 

lintOptions { 
    abortOnError false 
} 
packagingOptions { 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/maven/com.google.guava/guava/pom.properties' 
    exclude 'META-INF/maven/com.google.guava/guava/pom.xml' 
    exclude 'com.google.android.gms.measurement' 

} 
defaultConfig { 
    applicationId "com.elisiumlabs.sarthi" 
    minSdkVersion 10 
    targetSdkVersion 19 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 

    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
    } 
} 
compileOptions { 
    sourceCompatibility JavaVersion.VERSION_1_7 
    targetCompatibility JavaVersion.VERSION_1_7 
} 

} 

dependencies { 

compile project(':androidQuery') 
compile project(':pinnedSectionListActivity') 
compile project(':volley') 
compile project(':facebookSDK') 
compile 'com.google.code.gson:gson:2.2.4' 
compile 'joda-time:joda-time:2.3' 
compile 'com.android.support:gridlayout-v7:21.0.0' 
compile "com.google.android.gms:play-services-location:8.3.0" 
// compile "com.google.android.gms:play-services-gcm:8.3.0" 
compile 'com.android.support:appcompat-v7:21.0.3' 


compile('com.google.android.gms:play-services-gcm:8.3.0') { 
    exclude group: 'com.google.android.gms.measurement' 
} 
compile('com.google.firebase:firebase-core:9.0.2') 
     { 
      exclude group: 'com.google.android.gms.measurement' 
     } 
/*compile files('libs/appcompat_v7.jar')*/ 
compile files('libs/commons-io-1.4.jar') 
compile files('libs/commons-lang-2.4.jar') 
compile files('libs/httpclient-4.3.5.jar') 
/*compile files('libs/objectify-5.0.3.jar')*/ 
compile 'commons-codec:commons-codec:1.9' 
compile files('libs/splunk-mint-4.1.jar') 
testCompile 'junit:junit:4.12' 
// androidTestCompile 'com.android.support:support-annotations:21.0.0' 
androidTestCompile 'com.android.support.test:runner:0.4.1' 
androidTestCompile 'com.android.support.test:rules:0.4.1' 
// Optional -- Hamcrest library 
androidTestCompile 'org.hamcrest:hamcrest-library:1.3' 
// Optional -- UI testing with Espresso 
/* androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.1') { 
    // Necessary if your app targets Marshmallow (since Espresso 
    // hasn't moved to Marshmallow yet) 
    exclude group: 'com.android.support', module: 'support-annotations' 
}*/ 
androidTestCompile('com.android.support.test.espresso:espresso- contrib:2.2.2') { 
    // Necessary if your app targets Marshmallow (since Espresso 
    // hasn't moved to Marshmallow yet) 
    exclude group: 'com.android.support', module: 'support-annotations' 
    exclude group: 'javax.inject' 
    exclude group: 'com.android.support' 
} 
androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2'){ 
    // Necessary if your app targets Marshmallow (since Espresso 
    // hasn't moved to Marshmallow yet) 
    exclude group: 'com.android.support', module: 'support-annotations' 
} 
// Optional -- UI testing with UI Automator 
    androidTestCompile('com.android.support.test.uiautomator:uiautomator-v18:2.1.1'){ 
     // Necessary if your app targets Marshmallow (since the test runner 
     // hasn't moved to Marshmallow yet) 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 


} 
configurations.all { 
resolutionStrategy { 
    force 'com.android.support:support-annotations:23.0.1' 
} 
} 

Antwort

0

Konfigurieren des App für Multidex mit Gradle Referenz https://developer.android.com/studio/build/multidex.html#mdex-gradle

die Modulebene build.gradle Dateikonfiguration Ändern Sie die Support-Bibliothek aufzunehmen und multidex Ausgabefreigabe , wie im folgenden Code-Schnipsel gezeigt:

android { 
compileSdkVersion 21 
buildToolsVersion "21.1.0" 

defaultConfig { 
    ... 
    minSdkVersion 14 
    targetSdkVersion 21 
    ... 

    // Enabling multidex support. 
    multiDexEnabled true 
} 
... 
} 

dependencies { 
compile 'com.android.support:multidex:1.0.0' 
} 

erweitert die Anwendungsklasse, können Sie überschreiben Sie die attachBaseContext() -Methode und rufen Sie MultiDex.install (this) auf, um Multidex zu aktivieren. Weitere Informationen finden Sie in der Referenzdokumentation zu MultiDexApplication.

0

auf meine Antwort versuchen ....

Hier ist der Link

Android Studio Gradle Error:Execution failed for task ':app:dexDebug' using Ion koush lib

Bitte nehmen Sie den Google-Dienst als meine Antwort und auch zu Ihrem gradle einige Code hinzufügen, wie auch gezeigt addieren Sie etwas Code in Ihrer mainfiest Datei

Und auch das multiidexenable mit comile das multidex wie in Antwort

gezeigt

Erste Compile die Build mit

compile 'com.android.support:multidex:1.0.1'

compile 'com.google.android.gms:play-services:+'

in Ihrem AndroidManifest.xml diese Zeilen android hinzufügen: Name

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" 
    android:name="android.support.multidex.MultiDexApplication" 
    > 

und in Ihrer build.gradle auch hinzufügen

dexOptions { 
    //incremental = true; 
    preDexLibraries = false 
    javaMaxHeapSize "4g" 
} 
0

Ich glaube wirklich nicht, dass Sie GCM und FCM mischen könnten, weil FCM das neue GCM ist. Logischerweise müssen sie eine ähnliche Ähnlichkeit mit dem Interwork haben.

Sie sollten entweder FCM oder GCM wählen. Von Ihrem build.gradles aus sieht es so aus als ob Sie mit gcm arbeiten. Entfernen Sie den FCM-Code. Entfernen Sie die folgenden Zeilen:

compile('com.google.firebase:firebase-core:9.0.2') 
{ 
    exclude group: 'com.google.android.gms.measurement' 
} 

Lesen Sie den Play-Service-Setup mit GCM bei Setting Up Google Play Services und FCM bei Add Firebase to your Android Project.

0

Wenn ich versuche, und die Versionsstufen nicht übereinstimmen, gibt Android Studio die folgende Warnung:

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/)

somit auf die gleiche Versionsstufe Einstellung löst die Abhängigkeiten nicht miteinander

compile('com.google.android.gms:play-services-gcm:11.8.0') 
    compile('com.google.firebase:firebase-core:11.8.0') 
Arbeits
Verwandte Themen