合并dex文件时OneSignal-Firebase错误

时间:2017-12-25 18:13:12

标签: android firebase-cloud-messaging build.gradle onesignal dex

尝试将实现'com.onesignal:OneSignal:[3.6.5,3.99.99]'添加到我的app / build.gradle文件时出错。

Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/0.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/1.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/2.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/3.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/4.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/5.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/6.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/7.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/8.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/9.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/10.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/11.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/12.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/13.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/14.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/15.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/16.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/17.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/18.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/19.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/20.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/21.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/22.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/23.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/24.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/25.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/26.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/27.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/28.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/29.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/30.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/31.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/32.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/33.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/34.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/35.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/36.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/37.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/38.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/39.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/40.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/41.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/42.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/43.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/44.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/45.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/46.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/47.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/48.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/49.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/50.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/51.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/52.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/53.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/54.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/55.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/56.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/57.jar, /Users/fotis/android/my-app/app/build/intermediates/transforms/dexBuilder/debug/58.jar

Gradle Console输出。

* What went wrong:

Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

应用程序/的build.gradle

plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.0'
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "**********"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
        manifestPlaceholders = [onesignal_app_id: "*********",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }
    buildTypes {
        debug {
            buildConfigField "String", "facebook_access_token", (project.findProperty("FACEBOOK_GRAPH_ACCESS_TOKEN") ?: "")
            buildConfigField "String", "server_ip", (project.findProperty("SERVER_IP") ?: "")
        }
        release {
            buildConfigField "String", "facebook_access_token", (project.findProperty("FACEBOOK_GRAPH_ACCESS_TOKEN") ?: "")
            buildConfigField "String", "server_ip", (project.findProperty("SERVER_IP") ?: "")
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

realm {
    syncEnabled = true
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:preference-v7:26.1.0'
    implementation 'com.android.support:preference-v14:26.1.0'

    testImplementation 'junit:junit:4.12'


    // Core
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'

    // Realm
    implementation 'io.realm:android-adapters:2.1.1'

    // ButterKnife
    implementation 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

    // Picasso
    implementation 'com.squareup.picasso:picasso:2.5.2'

    // Firebase
    implementation 'com.firebase:firebase-jobdispatcher:0.5.0'
    // implementation 'com.google.firebase:firebase-core:11.6.0'
    implementation 'com.google.firebase:firebase-messaging:11.6.0'

    // OneSignal SDK
    implementation 'com.onesignal:OneSignal:[3.6.5, 3.99.99]'

    // Google
    implementation 'com.google.android.gms:play-services-location:11.6.0'
    implementation 'com.google.android.gms:play-services-maps:11.6.0'

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

的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "io.realm:realm-gradle-plugin:4.3.1"
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}



allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

只有在添加实现依赖项时才会出现问题。 我已经尝试过Clean Project,Rebuild,clean gradle task,Invalidate Caches和Restart,但仍然无效。

是否有人知道问题所在以及如何解决?

谢谢

0 个答案:

没有答案