无法合并dex。试过一切仍然无法正常工作

时间:2018-06-03 06:28:43

标签: android android-studio android-gradle

我试过: 1)清洁和重建。 2)multiDexEnabled true。

但仍然显示的错误是:错误:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDebug'。

  

java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

有任何建议如何解决,请帮忙?

我的应用级Gradle文件:

apply plugin: 'com.android.application'

android {
signingConfigs {
    config {
    }
}
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.hp.facebook_login"
    minSdkVersion 19
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
    }
}
}

repositories {
mavenCentral()
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.facebook.android:account-kit-sdk:4.33.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我的项目级别gradle文件:

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

buildscript {

repositories {
    google()
    jcenter()
    //for Facebook SDK
    mavenCentral()
}
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
    }
   }
   allprojects {
repositories {
    google()
    jcenter()
}
}
 task clean(type: Delete) {
delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:-1)

添加这几行有助于我成功删除错误: 这是新的应用程序级别gradle文件,您可以比较并查找更改。

    apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.hp.mkchat"
    minSdkVersion 19
    targetSdkVersion 27
    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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.android.support:support-v4:27.1.1-beta1'
implementation 'com.google.firebase:firebase-database:11.4.2'
implementation 'com.google.firebase:firebase-storage:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}

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