当我使用Android Studio构建我的应用程序时,我遇到了这个错误。APK已编译,但当我尝试在Android P模拟器上运行该应用程序时,它将崩溃并抛出以下错误。请在附件中查看更多详细信息:
java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion
这是我的build.grade文件。如果有人对这个问题有什么建议,我将不胜感激。非常感谢。
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'
}
发布于 2019-08-19 15:38:00
如果你使用Android 9.0和遗留的jar,那么你就必须使用。在你的mainfest文件中。
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
发布于 2018-06-07 16:27:34
安卓bug跟踪器也报道了这一点:https://issuetracker.google.com/issues/79478779
发布于 2020-01-30 15:43:30
如果您使用的是com.google.android.gms:play-services-maps:16.0.0
或更低版本,并且您的应用程序针对的是API28级(Android9.0)或更高版本,则必须在AndroidManifest.xml的元素中包含以下声明
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
https://stackoverflow.com/questions/50461881
复制相似问题