NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams;闪退

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节点下 添加以下内容:

<uses-library
    android:name="org.apache.http.legacy"
    android:required="false" />
<application
            android:name=".application.MyApplication"
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:largeHeap="true"
            android:theme="@style/QMUI.Compat.NoActionBar"
            tools:ignore="GoogleAppIndexingWarning">
        <!--android9闪退-->
        <uses-library
                android:name="org.apache.http.legacy"
                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"属性,如下:

<application
            android:name=".application.MyApplication"
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:largeHeap="true"
            android:theme="@style/QMUI.Compat.NoActionBar"
            android:usesCleartextTraffic="true"
            tools:ignore="GoogleAppIndexingWarning">
        <!--android9闪退-->
        <uses-library
                android:name="org.apache.http.legacy"
                android:required="false" />


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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值