Failed resolution of: Lorg/apache/http/params/BasicHttpParams;闪退 安卓升级28报错

Android9的问题

首先需要在AndroidManifest.xml文件的application标签里面加入

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

然后添加该权限:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

在AndroidManifest.xml的application节点下 添加以下内容:

 
  1. <uses-library

  2.     android:name="org.apache.http.legacy"

  3.     android:required="false" />

  4. <application

  5.             android:name=".application.MyApplication"

  6.             android:allowBackup="true"

  7.             android:icon="@mipmap/ic_launcher"

  8.             android:label="@string/app_name"

  9.             android:roundIcon="@mipmap/ic_launcher_round"

  10.             android:supportsRtl="true"

  11.             android:largeHeap="true"

  12.             android:theme="@style/QMUI.Compat.NoActionBar"

  13.             tools:ignore="GoogleAppIndexingWarning">

  14.         <!--android9闪退-->

  15.         <uses-library

  16.                 android:name="org.apache.http.legacy"

  17.                 android:required="false" />


加上这么一段代码之后呢,ClassNotFoundException的错是不报了,但是还是闪退,并给你一个

java.io.IOException: Cleartext HTTP traffic to xxx.xxx.xxx.xxx not permitted   

这样的错,网上找了一下据说是Android9.0 默认是禁止所有的http请求的,我们还需要在AndroidManifest.xml的application节点中加上android:usesCleartextTraffic="true"属性,如下:

 
  1. <application

  2.             android:name=".application.MyApplication"

  3.             android:allowBackup="true"

  4.             android:icon="@mipmap/ic_launcher"

  5.             android:label="@string/app_name"

  6.             android:roundIcon="@mipmap/ic_launcher_round"

  7.             android:supportsRtl="true"

  8.             android:largeHeap="true"

  9.             android:theme="@style/QMUI.Compat.NoActionBar"

  10.             android:usesCleartextTraffic="true"

  11.             tools:ignore="GoogleAppIndexingWarning">

  12.         <!--android9闪退-->

  13.         <uses-library

  14.                 android:name="org.apache.http.legacy"

  15.                 android:required="false" />


这样Android9闪退的问题就解决啦!

原文:https://blog.csdn.net/qq_36611526/article/details/89466341 

 

 

 

 

<application  
        android:usesCleartextTraffic="true">

在application 里面添加 android:usesCleartextTraffic="true"

 

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

在最后添加

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值