Apache DefaultHttpClient invocation results in “java.lang.RuntimeException: Stub!”

后端 未结 5 492
终归单人心
终归单人心 2020-12-18 08:31

I\'m dipping my toes into Android development. I have a project that will interface with a RESTful resource and I\'m trying to figure out how to do a basic GET with params o

5条回答
  •  没有蜡笔的小新
    2020-12-18 09:07

    This happens when using Proguard and the com.apache.http.legacy library in Android SDK 23.

    It worked after I added this to my Proguard config:

    -keep class org.apache.http.** { *; }
    -keep class org.apache.commons.codec.** { *; }
    -keep class org.apache.commons.logging.** { *; }
    -keep class android.net.compatibility.** { *; }
    -keep class android.net.http.** { *; }
    -keep class com.android.internal.http.multipart.** { *; }
    -dontwarn org.apache.http.**
    -dontwarn android.webkit.**
    

    Which allows the system Apache implementation to properly override the stubs compiled into the app.

提交回复
热议问题