java.lang.NoClassDefFoundError:解析失败:Lorg/apache/http/ProtocolVersion [英] java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion

查看:49
本文介绍了java.lang.NoClassDefFoundError:解析失败:Lorg/apache/http/ProtocolVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Android Studio 构建应用程序时遇到此错误.APK 已编译,但是当我尝试在 Android P 模拟器上运行该应用程序时,它会崩溃并抛出以下错误.请在附件中查看更多详细信息:

I'm encountering this error when I use Android Studio to build my app. The APK is compiled, but when I attempt to run the app on Android P emulator, it will crash and throw the following error. Please see more details in the attachments:

java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion

这是我的 build.grade 文件.如果有人对可能出现的问题有什么建议,我将不胜感激.非常感谢.

This is my build.grade file. If anybody has a suggestion on what the problem could be, I would appreciate it. Many thanks.

android {

     compileSdkVersion 'android-P'
     buildToolsVersion '28-rc1'
   
    useLibrary 'org.apache.http.legacy'

    //for Lambda
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {

        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    defaultConfig {
        applicationId "xxx.xxx.xxx"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode xxxx
        versionName "Vx.x.x"

        multiDexEnabled true
     

     //other setting required
        ndk {
            abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a', 'x86', 'x86_64', 'mips', 'mips64'
        }

推荐答案

更新:这不再是错误或解决方法,如果您的应用面向 API 级别 28 (Android 9.0) 或以上并使用适用于 Android 16.0.0 或以下版本的 Google Maps SDK(或者如果您的应用程序使用 Apache HTTP Legacy 库).它现在包含在官方文档中.公开问题已按照预期行为关闭.

Update: This is no longer a bug or a workaround, it is required if your app targets API Level 28 (Android 9.0) or above and uses the Google Maps SDK for Android 16.0.0 or below (or if your app uses the Apache HTTP Legacy library). It is now included in the official docs. The public issue has been closed as intended behavior.

这是 Google Play 服务方面的错误,在修复之前,您应该能够通过将其添加到 <application> 标签内的 AndroidManifest.xml 来解决:

This is a bug on the Google Play Services side, until it's fixed, you should be able to workaround by adding this to your AndroidManifest.xml inside the <application> tag:

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

这篇关于java.lang.NoClassDefFoundError:解析失败:Lorg/apache/http/ProtocolVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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