[英]Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion
I am using Google maps Android SDK 11.6.2(Also tried 15.0.1),but I get following crash before map shows.我正在使用 Google 地图 Android SDK 11.6.2(也尝试过 15.0.1),但是在地图显示之前我遇到了以下崩溃。 Already checked API key in manifest,it is available, but still this issue occurs.
清单中已经检查了 API 密钥,它可用,但仍然出现此问题。 I am having targetSDk version as 28.Is it causes this issue.
我的 targetSDk 版本为 28。是否会导致此问题。
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at el.b(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):3)
at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4)
at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51)
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11)
at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16)
at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/system/priv-app/PrebuiltGmsCorePi/app_chimera/m/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi-v7a, /data/user_de/0/com.google.android.gms/app_chimera/m/00000036/MapsDynamite.apk!/lib/armeabi, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader@12848063@12.8.48 (100408-196123505):25)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at el.b(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):3)
at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4)
at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51)
at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11)
at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16)
at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61)
Put this in the Manifest <application>
tag:把它放在 Manifest
<application>
标签中:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
More info: https://issuetracker.google.com/issues/79478779更多信息: https : //issuetracker.google.com/issues/79478779
This will resolve your crash.这将解决您的崩溃。 Apply this in manifest
在清单中应用它
<application
...
>
...
<uses-library android:name="org.apache.http.legacy"
android:required="false"/>
...
<application/>
Do one of the following solutions:执行以下解决方案之一:
1- Update the play-services-maps library to latest version: 1- 将 play-services-maps 库更新到最新版本:
com.google.android.gms:play-services-maps:16.1.0
2- Or include the following declaration within the <application>
element of AndroidManifest.xml
. 2- 或者在
AndroidManifest.xml
的<application>
元素中包含以下声明。
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the <application>
element of AndroidManifest.xml.如果您的应用面向 API 级别 28 (Android 9.0) 或更高版本,则必须在 AndroidManifest.xml 的
<application>
元素中包含以下声明。
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element of AndroidManifest.xml.如果您的应用面向 API 级别 28 (Android 9.0) 或更高版本,则必须在 AndroidManifest.xml 的元素中包含以下声明。 see the behavioral changes of app targeting 28+ in the below link
在下面的链接中查看面向 28 岁以上的应用程序的行为变化
https://developer.android.com/about/versions/pie/android-9.0-changes-28 https://developer.android.com/about/versions/pie/android-9.0-changes-28
如果这发生在 Android 8.0 或更高版本中,那么只需将此行放在您的清单应用程序标签中
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Set tis:设置:
multiDexEnabled true
Like this:像这样:
android {
compileSdkVersion 28
defaultConfig {
multiDexEnabled true
}
buildTypes {
release {
}
}
}
create an xml file res/xml/network_security_config.xml创建一个 xml 文件 res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
And add 2 tags tag in your AndroidManifest.xml并在您的 AndroidManifest.xml 中添加 2 个标签
<?xml version="1.0" encoding="utf-8"?>
<manifest......>
<application android:networkSecurityConfig="@xml/network_security_config">
<activity..../>
......
......
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
</application>
Also add useLibrary 'org.apache.http.legacy' in your app build gradle还要在您的应用程序构建 gradle 中添加 useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.ascorb"
minSdkVersion 19
targetSdkVersion 28
versionCode 6
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
}
Add permissions in Manifest file在清单文件中添加权限
`<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION."/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>`
and in part put this line of code部分地把这行代码
` <uses-library android:name="org.apache.http.legacy" android:required="false"/>`
I had the same problem and It was fixed by this.我有同样的问题,它已通过此修复。
Here is the solution这是解决方案
<uses-library android:name="org.apache.http.legacy" android:required="false" />
Adding this line to your Menifest.xml inside <application>
tag将此行添加到
<application>
标记内的 Menifest.xml
for more info欲了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.