Ошибка Android: невозможно объединить dex - PullRequest
0 голосов
/ 29 мая 2018
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Я получил следующую ошибку

Это мой сборщик

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.ryan.mychatapp"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-storage:11.2.0'
    //noinspection GradleCompatible
    compile 'com.google.android.gms:play-services:11.2.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.google.firebase:firebase-database:11.2.0'

    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:11.2.0'
    compile 'com.google.firebase:firebase-database:11.2.0'
    compile 'com.google.firebase:firebase-messaging:11.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    testImplementation 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    implementation 'com.firebaseui:firebase-ui-database:2.1.1'
    compile 'id.zelory:compressor:2.1.0'
}

Это мой очередной сборщик

// 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'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

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

Я уже добавил multiDexEnabledправда, но ошибка продолжает появляться.Я уже пытался, очистить и восстановить, но ничего не работает, что мне делать?Я не уверен, что не так с моим gradle?В этот пост я вставил весь свой gradle.

Дайте мне знать, какую часть я должен изменить

1 Ответ

0 голосов
/ 29 мая 2018

Вы смешиваете реализацию и компиляцию, просто используйте реализацию для всех ваших зависимостей, так как компиляция устарела.Также обновите ваш плагин Gradle.

dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }


dependencies {
    //noinspection GradleCompatible
    implementation 'com.google.firebase:firebase-storage:11.2.0'
    //noinspection GradleCompatible
    implementation 'com.google.android.gms:play-services:11.2.0'
    implementation 'com.android.support:support-v4:26.1.0'
    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.google.firebase:firebase-database:11.2.0'

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-auth:11.2.0'
    implementation 'com.google.firebase:firebase-database:11.2.0'
    implementation 'com.google.firebase:firebase-messaging:11.2.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:multidex:1.0.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    implementation 'com.squareup.okhttp:okhttp:2.5.0'
    implementation 'com.firebaseui:firebase-ui-database:2.1.1'
    implementation 'id.zelory:compressor:2.1.0'
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...