解决 Android java.lang.RuntimeException: Stub!

错误堆栈:

    java.lang.RuntimeException: Stub!
        at org.apache.http.message.AbstractHttpMessage.<init>(SourceFile:7)
        at org.apache.http.client.methods.HttpRequestBase.<init>(SourceFile:7)
        at org.apache.http.client.methods.HttpEntityEnclosingRequestBase.<init>(SourceFile:7)
        at org.apache.http.client.methods.HttpPost.<init>(SourceFile:8)
        at com.tencent.stat.StatDispatcher.sendHttpPost(Unknown Source:104)
        at com.tencent.stat.StatDispatcher$2.run(Unknown Source:6)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:224)
        at android.os.HandlerThread.run(HandlerThread.java:65)

原因:

在android 9.0 ,Apache HTTP client, 已经从bootClassLoader 里面移除了。

我们可以看下android 官网自己说的:
在这里插入图片描述

解决方法:

在清单里面,加上下面这句:

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

加的位置是在application节点里面,如下图:
在这里插入图片描述

注意:

这个只会对target 升级到android 9.0 及以上的应用,才会报这个错误。如果没有升级target,那么不会报错。java.lang.RuntimeException: Stub!

参考:

https://developer.android.com/about/versions/pie/android-9.0-changes-28

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值