ugola
ugola

Reputation: 347

org.apache.http.client.utils.URIBuilder in Android?

Unable to import import org.apache.http.client.utils.URIBuilder; in android. Can anyone tell me why?

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.u.g.c"
        minSdkVersion 11
        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(dir: 'libs', include: ['*.jar'])
    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'
    testCompile 'junit:junit:4.12'
}

I had already been using the useLibrary 'org.apache.http.legacy' . But still I am unable to import it.

Upvotes: 0

Views: 2015

Answers (2)

Sandeep dhiman
Sandeep dhiman

Reputation: 1921

I think your gradle version is not updated

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

} this only works if you are using gradle 1.3.0-beta2 or greater, so you will have to add this to buildscript dependencies if you are on a lower version:

classpath 'com.android.tools.build:gradle:1.3.0-beta2'

Add below line too in your gradle file

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

Upvotes: 1

Chirag
Chirag

Reputation: 56925

Apache http has been deprecated in api 23.

For android studio add this line in build.gradle

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

Another way is,

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

Upvotes: 0

Related Questions