Ich möchteDuplicate Files in APK Kopierte - Android
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
Ich habe useLibrary 'org.apache.http.legacy'
in Android hinzugefügt verwenden {} Tags in build.gradle (App) und haben compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
in meiner Abhängigkeiten hinzugefügt. Meine app (build.gradle)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.abc.ggg.app1"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
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'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.microsoft.cognitive:speakerrecognition:1.1.0'
testCompile 'junit:junit:4.12'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}
Mein Projekt (build.gradle)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Ich habe nach Antworten gesucht, aber nichts löst mein Problem. Ich erhalte eine Fehlermeldung -
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
und
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.3\5b0002c5fb66867ca919be0fbd86de1cfaf76da7\httpmime-4.3.jar
File2: C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient-android\4.3.5.1\eecbb0b998e77629862a13d957d552b3be58fc4e\httpclient-android-4.3.5.1.jar
Bitte um Hilfe! :(
Sie brauchen nur Legacy-Bibliothek .Entfernen Sie 'compile group: 'org.apache.httpcompon "," "httpclient-android", Version: "4.3.5.1" in dieser Zeile. httpcomponents werden 2 mal hinzugefügt, dh warum du DuplicateFileException bekommst. –