Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex_Java_Android_Gradle - Fatal编程技术网

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

错误:java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex,java,android,gradle,Java,Android,Gradle,错误:java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 错误:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 错误:com.android.builder.dexing.DexArchiveM

错误:java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 错误:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 错误:com.android.builder.dexing.DexArchiveMergerException:无法合并dex 错误:com.android.dex.DexException:多个dex文件定义Lorg/apache/http/conn/socket/LayeredConnectionSocketFactory

错误:java.lang.RuntimeException:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException:无法合并 指数

您应该升级您的
gms:play服务
com.android.support
版本

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

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

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




apply plugin: 'com.android.application'

android {
    signingConfigs {
    }
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId 'net.example.net.app'
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/DEPENDENCIES'
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile('org.apache.httpcomponents:httpmime:4.3.4') {
        exclude module: 'org.apache.httpcompoents:httpcore'
        exclude module: 'org.apache.httpcompoents:httpclient'
    }
    compile 'org.codehaus.jackson:jackson-core-asl:1.8.3'
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.8.3'
}
在此之后,
清除重建运行

FYI

启用


您已启用多索引,但未添加依赖项,请在依赖项中添加以下内容

 defaultConfig {
        multiDexEnabled true
    }
然后确保您的应用程序类扩展了多索引应用程序。最后清理和重建项目。希望这能解决问题


要了解更多信息,请检查,这是因为HttpTime在其依赖项中包含httpclient。你需要排除它。当前,您使用了错误的包名称来排除httpclient:

compile 'com.android.support:multidex:1.0.2'
应该是:

compile('org.apache.httpcomponents:httpmime:4.3.4') {
    exclude module: 'org.apache.httpcompoents:httpcore'
    exclude module: 'org.apache.httpcompoents:httpclient'
}

如果您在phonegap/cordova中遇到此错误,请不要浪费时间,返回并在不同的路径上重新生成新项目。它在我的情况下起作用

compile('org.apache.httpcomponents:httpmime:4.3.4') {
    exclude module: 'org.apache.httpcompoents:httpcore'
    exclude module: 'org.apache.httpcompoents:httpclient'
}
compile('org.apache.httpcomponents:httpmime:4.3.4') {
   exclude group: 'org.apache.httpcomponents', module: 'httpcore'
   exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}