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
Google officially suggests to developers to use Volley library for networking related stuff Here, so Its time to switch to Volley, Happy coding
HttpClient is not supported any more in sdk 23. You have to use URLConnection or downgrade to sdk 22 (compile 'com.android.support:appcompat-v7:22.2.0')
If you need sdk 23, add this to your gradle:
In dependencies add:
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
and also add this
android {
useLibrary 'org.apache.http.legacy'
}
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.
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
You just rebuilt your project
compile fileTree(dir: 'libs', include: ['*.jar'])
For me, the below helped
Find org.apache.http.legacy.jar
which is in Android/Sdk/platforms/android-23/optional,
add it to your dependency.
Source
please add these codes to your dependencies. It will work.
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:23.1.0'
implementation 'com.android.support:design:23.1.0'
implementation 'com.android.support:cardview-v7:23.1.0'
implementation 'com.android.support:recyclerview-v7:23.1.0'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}