Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio

前端 未结 12 1941
深忆病人
深忆病人 2020-12-02 12:47

I just copy all the jar files of Http but Android Studio cann\'t import all these jar files.It gives an error : Cannot resolve symbol HttpGe

相关标签:
12条回答
  • 2020-12-02 13:38

    HttpClient was deprecated in API Level 22 and removed in API Level 23. You have to use URLConnection.

    0 讨论(0)
  • 2020-12-02 13:40

    That is just in SDK 23, Httpclient and others are deprecated. You can correct it by changing the target SDK version like below:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
        defaultConfig {
            applicationId "vahid.hoseini.com.testclient"
            minSdkVersion 10
            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'])
        compile 'com.android.support:appcompat-v7:22.1.1'
    }
    
    0 讨论(0)
  • 2020-12-02 13:41

    Just add this line of code in your build.gradle file and it will work.

    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    

    Also add these below line if above did not work at all.

    compile 'com.google.android.gms:play-services:+'
    compile ('org.apache.httpcomponents:httpmime:4.2.6'){
        exclude module: 'httpclient'
    }
    compile 'org.apache.httpcomponents:httpclient:4.2.6'
    
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpclient:4.5'
    
    0 讨论(0)
  • 2020-12-02 13:42

    Please remove all jar files of Http from 'libs' folder and add below dependencies in gradle file:

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

    or

    useLibrary 'org.apache.http.legacy'
    
    0 讨论(0)
  • 2020-12-02 13:46

    Please remove all jar files of Http from libs folder and add below dependencies in gradle file :

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

    Thanks.

    0 讨论(0)
  • 2020-12-02 13:47

    adding this worked for me.

    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    
    0 讨论(0)
提交回复
热议问题