2015-04-08 16 views
5

Ich bin Abhängigkeiten in build.gradle Datei hinzufügen.Android Gradle Erstellungsfehler

Mein Code ist:

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:21.0.3' 
compile 'com.google.android.gms:play-services:6.1.11' 
compile 'org.apache.httpcomponents:httpmime:4.4.1' 
compile 'org.apache.httpcomponents:httpcore:4.4.1' 
compile 'org.apache.httpcomponents:httpclient:4.4.1' 

}

ich eine Fehlermeldung anzeigt:

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. 
    In case of problem, please repackage it with jarjar to change the class packages 

Wie dieses Problem zu lösen. Bitte helfen Sie mir?

Antwort

8

Sie können versuchen, indem Sie dies in Ihrem build.gradle (Modul: app) hinzufügen. Es löste mein Problem:

packagingOptions{ 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
} 

Meine letzte Build gradle wie folgt aussieht:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "info.androidhive.camerafileupload" 
     minSdkVersion 19 
     targetSdkVersion 21 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
    packagingOptions{ 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
    } 
} 

dependencies { 
    compile 'com.android.support:appcompat-v7:21.0.3' 
    compile files('libs/httpclient-4.3.6.jar') 
    compile files('libs/httpcore-4.3.3.jar') 
    compile files('libs/httpmime-4.3.6.jar') 
} 

NB: In meinem Fall habe ich diese 3 Gläser in meinem libs Ordner eingefügt haben. Sie können herunterladen und tun.

+0

Ja seine Arbeit @Mohammad Arman – nmkkannan

+0

Ja seine Arbeits .. –

+0

Gute Antwort! Danke, – Tino

4

Ich löste dieses Problem durch folgende Zeile ersetzt folgende URL

compile "org.apache.httpcomponents:httpclient:4.4.1" 

mit diesem

compile "org.apache.httpcomponents:httpclient-android:4.3.5.1" 

Bitte besuchen Sie, wenn Sie

https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html

mehr über Httpclient für Android wissen wollen
+0

Dieses funktioniert nicht, wenn wir MultipartEntity Klasse benutzen – VVB

2

löste ich das Problem durch Verwendung dieser Bedienungsanleitung, wenn Ihr compileSdkVersion 19 ist (in meinem Fall)

compile ('org.apache.httpcomponents:httpmime:4.3'){ 
    exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
} 
compile ('org.apache.httpcomponents:httpcore:4.4.1'){ 
    exclude group: 'org.apache.httpcomponents', module: 'httpclient' 
} 
compile 'commons-io:commons-io:1.3.2' 

sonst, wenn Ihr compileSdkVersion 23 dann

verwenden
android { 
useLibrary 'org.apache.http.legacy' 
packagingOptions { 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    } 
} 
2

Statt exclude zu jeder Bibliothek hinzuzufügen, Sie folgende Konfiguration für alle Bibliotheken hinzufügen:

configurations { 
    all*.exclude group: 'org.apache.httpcomponents',module: 'httpclient' 
} 
1

Wenn nichts dieses ein .d funktioniert versuchen Definitely arbeiten

dieses

ersetzen
dependencies { 
...... 
....... 
    compile 'org.apache.httpcomponents:httpclient:4.4.1' 
} 

mit folgenden Code

dependencies { 
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' 
}