I've already tried multiDexEnabled true
and changing the minSdkVersion 18
and compileSdkVersion 26
and it didm't work.
The library that is causing the error is:
'libs/httpmime-4.5.5.jar'
I've also tried with multiple versions of mime, the 4.0 and 4.1 doesn't give an error but it doesn't have the MultipartEntityBuilder
so I can't use it, and after 4.2 it give me the error
Error:Execution failed for task
:app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
when building.
my gradle file is:
Edit: change Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "ags.ventas"
minSdkVersion 18
multiDexEnabled true
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation 'com.android.support:recyclerview-v7:26.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
debugCompile 'com.amitshekhar.android:debug-db:1.0.1'
// HTTP requests
compile 'com.android.support:appcompat-v7:26.1.0'
// Google Services
compile 'com.google.android.gms:play-services-maps:11.6.0'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:support-v4:26.1.0'
testCompile 'junit:junit:4.12'
compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
compile 'org.igniterealtime.smack:smack-android:4.2.0'
compile 'org.igniterealtime.smack:smack-experimental:4.2.0'
compile 'org.igniterealtime.smack:smack-tcp:4.2.0'
compile 'org.igniterealtime.smack:smack-im:4.2.0'
compile 'org.igniterealtime.smack:smack-sasl-provided:4.2.0'
implementation('org.apache.httpcomponents:httpmime:4.5.5') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
mavenCentral()
}
Edit:
I don't know why but gradle finaly show the error
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define
Lorg/apache/http/entity/mime/content/StringBody;
Edit 2
I found the solution, is not the cleanest but works
Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser
I'm using the this lib: https://code.google.com/p/httpclientandroidlib/ Is the same as the other but with different package name.
Thanks to all.