1

In my project I am using httpclient

URL url = new URL(link);
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet();

The gradle was as follows

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "abc.mobsoln.com.myproj"
        minSdkVersion 15
        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'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}

It was showing error - Cannot resolve symbol HttpClient

Actually, as you might be knowing - the issue was - because - HttpClient is not supported in ver 23. So I modified the gradle as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.2.1"

    defaultConfig {
        applicationId "abc.mobsoln.com.myproj"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.1'
}

After changing & build it shown a link -- Install missing platform & sync

To install: - Android SDK Platform 22 (platforms;android-22) Installing Android SDK Platform 22 Downloading https://dl.google.com/android/repository/android-22_r02.zip

SO I installed it .

After that it asks for update of Build Tool as well...

Install Build Tools 22.2.0 and sync project

This brings in the following error!

enter image description here

Pl suggest a fix for this.

I am ready to try any other fix from scratch. Pl suggest the best approach - as this is going to be generic issue for this version (& probably the coming ones). Pl suggest your fix fully instead of mere links... I have tried couple of that

Seb Thomas
  • 107
  • 1
  • 14

2 Answers2

0

All you have to do is just add below line in your build Gradle file.

android{
         useLibrary 'org.apache.http.legacy'
    }
Atul Singh
  • 175
  • 1
  • 14
0

Ref: https://stackoverflow.com/a/32323624/1474899

if you are using target sdk as 23 add below code in your build.gradle

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

and change your buildscript to

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

ONCE YOU DO THIS, BUILD & FOLLOW THE INSTRUCTIONS SHOWN BY THE STUDIO

Community
  • 1
  • 1
Seb Thomas
  • 107
  • 1
  • 14