Android解决禁止使用http协议的方案
android禁止使用http协议,出现闪退以及“Java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry”报错信息
解决方案:
1、针对android9.0以下系统
在build.gradle文件中添加
android{
useLibrary 'org.apache.http.legacy'
}
2、针对android9.0系统
在AndroidManifest.xml文件的application标签里面加入
<application
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>