如何在Android P上使用apache http [英] How to use apache http on Android P

查看:2077
本文介绍了如何在Android P上使用apache http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Android P 设备中运行我的应用时,我收到如下错误:

When I run my app in Android P devices, I get some error like this:

java.lang.RuntimeException: Unable to instantiate application com.le.android.client.LeApplication: java.lang.ClassNotFoundException: Didn't find class "com.le.android.client.LeApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/base.apk"],nativeLibraryDirectories=[/data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/lib/arm, /data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/base.apk!/lib/armeabi, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1009)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5836)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6649)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.le.android.client.LeApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/base.apk"],nativeLibraryDirectories=[/data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/lib/arm, /data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/base.apk!/lib/armeabi, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1001)
... 9 more

如何在 Android P 中使用库 org.apache.http.legacy

推荐答案

我读了 Android P行为更改,我收到一些消息:

I read the Android P behavior changes,and I get some messages:


Apache HTTP客户端弃用
使用Android 6.0,我们删除了对Apache HTTP客户端的支持。
从Android P开始,该库将从
bootclasspath中删除,默认情况下不适用于应用。

Apache HTTP client deprecation With Android 6.0, we removed support for the Apache HTTP client. Beginning with Android P, that library is removed from the bootclasspath and is not available to apps by default.

继续使用Apache HTTP客户端,针对Android P及更高版本的
应用必须在AndroidManifest.xml中添加以下内容:

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

注意:android:必需对于最低SDK为23或更低的应用程序,需要=false属性,因为在API级别低于24的设备上,org.apache.http.legacy库不可用。 (在这些设备上,Apache HTTP类在bootclasspath上可用。)

Note: The android:required="false" attribute is required for apps that mave a minimum SDK of 23 or lower, because on devices with API levels lower than 24, the org.apache.http.legacy library is not available. (On those devices, the Apache HTTP classes are available on the bootclasspath.)

这篇关于如何在Android P上使用apache http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆