Android9.0_P:ClassNotFoundException: Didn't find class "org.apache.http.conn.scheme.SchemeRegistry"

出现此问题的机型:小米 MIX 2S,系统版本为:9。

解决方案见官方文档:https://developer.android.google.cn/about/versions/pie/android-9.0-changes-28

Apache HTTP 客户端弃用

在 Android 6.0 中,我们取消了对 Apache HTTP 客户端的支持。 从 Android 9 开始,默认情况下该内容库已从 bootclasspath 中移除且不可用于应用。

要继续使用 Apache HTTP 客户端,以 Android 9 及更高版本为目标的应用可以向其 AndroidManifest.xml的application节点下 添加以下内容:

 

        
        
        
            
                

                
            
        
        
    

注:拥有最低 SDK 版本 23 或更低版本的应用需要 android:required="false" 属性,因为在 API 级别低于 24 的设备上,org.apache.http.legacy 库不可用。 (在这些设备上,Apache HTTP 类在 bootclasspath 中提供。)

作为使用运行时 Apache 库的替代,应用可以在其 APK 中绑定自己的 org.apache.http 库版本。 如果进行此操作,您必须将该库重新打包(使用一个类似 Jar Jar 的实用程序)以避免运行时中提供的类存在类兼容性问题。

具体错误日志截图如下:

09-18 10:24:20.403 5045-5211/? E/AndroidRuntime: FATAL EXCEPTION: Thread-20
    Process: com.chiigu.shake, PID: 5045
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/conn/scheme/SchemeRegistry;
        at com.tencent.open.utils.HttpUtils.getHttpClient(ProGuard:626)
        at com.tencent.open.utils.HttpUtils.openUrl2(ProGuard:506)
        at com.tencent.open.utils.f$1.run(ProGuard:197)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.conn.scheme.SchemeRegistry" on path: DexPathList[[zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/base.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_resources_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_5_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_6_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_7_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_8_apk.apk", zip file "/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/base.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_resources_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_slice_9_apk.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.tencent.open.utils.HttpUtils.getHttpClient(ProGuard:626) 
        at com.tencent.open.utils.HttpUtils.openUrl2(ProGuard:506) 
        at com.tencent.open.utils.f$1.run(ProGuard:197) 
    	Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.chiigu.shake-HVkLaDhGt3nHY1MsJYBgBg==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:354)
        at dalvik.system.DexFile.(DexFile.java:101)
        at dalvik.system.DexFile.(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:74)
        at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
09-18 10:24:20.404 5045-5211/? E/AndroidRuntime:     at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
        at android.app.LoadedApk.getResources(LoadedApk.java:1032)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
        at android.app.ActivityThread.access$1100(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        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:858)

 

你可能感兴趣的:(android开发问题)