问题
I am trying to parse json from url, Apache http client removed from Android API level 23. If I use httpclient.jar
files in android studio, it shows error like:
"Warning:Dependency org.json:json:20090211 is ignored for debug as it may be conflicting with the internal version provided by Android."
dependencies{
compile files('libs/httpclient-4.5.1.jar')
compile files('libs/httpcore-4.5.1.jar')
}
How to resolve this error.
Thank you.
回答1:
Remove the above two statements from your build.gradle
and add the following dependency
dependencies {
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
回答2:
if you just want to use apache client in sdk23. doDo you try to useadd this code in gradle.
android {
useLibrary 'org.apache.http.legacy'
}
see HttpClient won't import in Android Studio
回答3:
this is my gradle file
apply plugin: 'com.android.application'
android { compileSdkVersion 22 buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.myapplication"
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'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'com.github.nkzawa:engine.io-client:0.6.0'
compile 'com.github.nkzawa:socket.io-client:0.6.0'
compile 'com.github.rey5137:material:1.2.1'
compile files('libs/volley.jar')
compile files('libs/httpclient-4.5.1.jar')
compile files('libs/httpcore-4.5.1.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
来源:https://stackoverflow.com/questions/32930966/apache-http-client-error-with-json-version-provided-by-android