Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio

前端 未结 12 2032
深忆病人
深忆病人 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:32

    Just add this in your dependencies

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

    Finally

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])    
    testCompile 'junit:junit:4.12'
    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'
    }
    

    And also add this code:

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

    FYI

    Specify requirement for Apache HTTP Legacy library If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element of AndroidManifest.xml.

     
    

提交回复
热议问题