HttpClient does not work in my Android Studio 1.4

Sorry for my bad English first, I'm new to android studio 1.4, I get an error in HttpClient

Mistake

C:\Users\madhu\AndroidStudioProjects\LoginAndsign\app\src\main\java\com\login\loginandsign\SimpleHttpClient.java

Error:(27, 20) error: cannot find symbol class HttpClient

Error:(34, 20) error: cannot find symbol class HttpClient

Error:(36, 31) error: cannot find symbol class DefaultHttpClient

Error:(40, 13) error: cannot find symbol variable ConnManagerParams


Error:(57, 13) error: cannot find symbol class HttpClient

Error:(58, 13) error: cannot find symbol class HttpPost

Error:(58, 36) error: cannot find symbol class HttpPost

Error:(59, 13) error: cannot find symbol class UrlEncodedFormEntity

Error:(59, 51) error: cannot find symbol class UrlEncodedFormEntity

Error:(96, 13) error: cannot find symbol class HttpClient

Error:(97, 13) error: cannot find symbol class HttpGet

Error:(97, 35) error: cannot find symbol class HttpGet

I have added below dependencies, but at the same time it shows the same error

dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'org.apache.httpcomponents:httpclient:4.2.6'
compile 'org.apache.httpcomponents:httpmime:4.2.6'
compile files('libs/core.jar')
}
+4
source share
6 answers

HttpClienthas been removed in Android 6.0 .

To continue using HttpClient, add the code below to build.gradle:

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

You need to initialize useLibrary 'org.apache.http.legacy'

Please check HttpClient will not be imported into Android Studio

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1' 


    defaultConfig {
        minSdkVersion // set yours 
        targetSdkVersion 23
        versionCode 11 //Yours
        versionName "0.1" // Yours
    }

dependencies {
compile 'com.google.android.gms:play-services:7.8.0'
compile 'org.apache.httpcomponents:httpmime:4.2.6'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile files('libs/core.jar')
}

Then Clean-Rebuild-Restart-Sync is your project.

+3
source

 compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
+2

, gradle root build.gradle.

dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0' 
        // Lowest version for useLibrary is 1.3.0
        // Android Studio will notify you about the latest stable version
        // See all versions: http://jcenter.bintray.com/com/android/tools/build/gradle/
    }
+2

sdk 23, build.grade   build.gradle -/app/build.gradle

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

and change your buildscript to
**Top level build.gradle - /build.gradle**

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

Android

+1

, ,

, android-sdk-windows\platforms\android-23\optional\optional.json .

, API 23 , .

0

Source: https://habr.com/ru/post/1626294/


All Articles