Apache http client error with json version provided by android

老子叫甜甜 提交于 2019-12-13 02:01:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!