-2

Do i need to add any jar file. or need to and any dependencies

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "21.1.2"
    defaultConfig {

    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

buildTypes {
    release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    compile   'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.  client:4.1.2'
    compile "org.apache.httpcomponents:httpmime:4.2.3"
 }

And it displays this error in console:

Warning:Dependency org.apache.httpcomponents:httpclient:4.5 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.5 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

user000
  • 29
  • 2
  • 7

1 Answers1

0

On the contrary, you need to remove a dependency. The warning message is telling you that you're trying to import a dependency that's already included in Android. So you might not need the line

compile 'org.apache.httpcomponents:httpclient:4.5' #Try removing this line

Try removing it and see if the app works correctly. If it doesn't and you still need to import HttpClient, please refer to this page (it's posted just a few days go by apache.org, it doesn't get any more official than that).

The link above basically tells you that you should use:

Apache HttpClient 4.3 port for Android when targeting Android API 22 and older

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

or

Apache HttpClient packages for Android maintained by Marek Sebera when targeting Android API 23 and newer

dependencies {
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
}
Fikra
  • 3
  • 1
  • 1
  • It shows error you are using unsused imports import org.apache.http.client.ClientProtocolException; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.impl.client.DefaultHttpClient; – user000 Nov 20 '15 at 07:06
  • Is it an error or a warning? If it's an error, it has a red color. But if it's a warning, it should have a yellow color. Also, try auto importing your libraries as explained [here](http://stackoverflow.com/questions/16615038/what-is-the-shortcut-to-auto-import-all-in-android-studio) – Fikra Nov 21 '15 at 09:44