// 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'
}
错误: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;
答案 0 :(得分:2)
错误:java.lang.RuntimeException:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException:无法合并 DEX
您应升级 gms:play-services
& com.android.support
版本。
compile 'com.google.android.gms:play-services:11.6.0' //11.8.0
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.2'
之后, Clean-Rebuild-Run
。
<强> FYI 强>
defaultConfig {
multiDexEnabled true
}
答案 1 :(得分:0)
您已启用Multidex但错过了添加依赖项,请在依赖项中添加以下内容
compile 'com.android.support:multidex:1.0.2'
然后确保您的应用程序类扩展了MultidexApplication。最后清理并重建项目。希望这能解决问题
答案 2 :(得分:0)
这是因为httpmime在其依赖项中包含httpclient。你需要排除它。目前,您使用错误的包名称来排除httpclient:
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'
}
答案 3 :(得分:0)
如果你使用phonegap / cordova出现这个错误,那么不要浪费你的时间回去并在不同的路径上重新生成新项目。它在我的条件下工作