How to Add Apache Http API (Legacy) as Compile-Time Dependency to Build.Grade for Android M

How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?

For API 23:

Top level build.gradle - /build.gradle

buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
...

Module specific build.gradle - /app/build.gradle

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}

Official docs (for preview though): http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client

Latest android gradle plugin changelog: http://tools.android.com/tech-docs/new-build-system

How to use Legacy Apache in Eclipse in order to support Android M

Find org.apache.http.legacy.jar which is in Android/Sdk/platforms/android-23/optional, add it to your dependency.

How to add compile time dependency in eclipse

@SENTHILKUMAR S You should use Android Studio .

useLibrary adds the library to classpath while compiling but does not bundle the library with the application. Courtesy @laalto Sir .

Please upgrade the Gradle tools version in your build.gradle file of Android Studio , as follows:

dependencies {
classpath 'com.android.tools.build:gradle:1.3.0' //2.3.0
}

For more info you can check

How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?

Apache HttpClient Android (Gradle)

If you are using target SDK as 23 add the below code in your build.gradle

android{
useLibrary 'org.apache.http.legacy'
}

Additional note here: don't try using the gradle versions of those files. They are broken (28.08.15). I tried over 5 hours to get it to work. It just doesn't.
not working:

compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'

Another thing don't use:

'org.apache.httpcomponents:httpclient-android:4.3.5.1'

It's referring to 21 API level.

Apache HTTP library not working in API 27

Check inside your SDK Path org.apache.http.legacy.jar is available?

D:\android-sdk-windows\platforms\android-27\optional\

copy that into your Lib folder and add dependancy in your gradle then compile it.



Related Topics



Leave a reply



Submit