Home » Android » Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion

Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion

Posted by: admin March 10, 2020 Leave a comment

Questions:

I am using Google maps Android SDK 11.6.2(Also tried 15.0.1),but I get following crash before map shows. Already checked API key in manifest,it is available, but still this issue occurs. I am having targetSDk version as 28.Is it causes this issue.

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
        at el.b(:[email protected]@12.8.48 (100408-196123505):3)
        at ek.a(:[email protected]@12.8.48 (100408-196123505):4)
        at em.a(:[email protected]@12.8.48 (100408-196123505):51)
        at com.google.maps.api.android.lib6.drd.ap.a(:[email protected]@12.8.48 (100408-196123505):11)
        at dw.a(:[email protected]@12.8.48 (100408-196123505):16)
        at dw.run(:[email protected]@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(:[email protected]@12.8.48 (100408-196123505):25)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at el.b(:[email protected]@12.8.48 (100408-196123505):3) 
        at ek.a(:[email protected]@12.8.48 (100408-196123505):4) 
        at em.a(:[email protected]@12.8.48 (100408-196123505):51) 
        at com.google.maps.api.android.lib6.drd.ap.a(:[email protected]@12.8.48 (100408-196123505):11) 
        at dw.a(:[email protected]@12.8.48 (100408-196123505):16) 
        at dw.run(:[email protected]@12.8.48 (100408-196123505):61) 
How to&Answers:

Put this in the Manifest <application> tag:

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

More info:
https://issuetracker.google.com/issues/79478779

Answer:

This will resolve your crash.
Apply this in manifest

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


<application/>

Answer:

Do one of the following solutions:

1- Update the play-services-maps library to latest version:

com.google.android.gms:play-services-maps:16.1.0

2- Or include the following declaration within the <application> element of AndroidManifest.xml.

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

Answer:

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.

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

Answer:

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.
see the behavioral changes of app targeting 28+ in the below link

https://developer.android.com/about/versions/pie/android-9.0-changes-28
https://developer.android.com/about/versions/pie/android-9.0-changes-28

Answer:

If this happen in Android 8.0 or above then just put this line in your manifest application tag

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

Answer:

Set tis:

multiDexEnabled true

Like this:

android {
    compileSdkVersion 28
    defaultConfig {

        multiDexEnabled true

    }
    buildTypes {
        release {

        }
    }
}

Answer:

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.

Answer:

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

for more info

Answer:

create an xml file 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

<?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

defaultConfig {
        applicationId "com.ascorb"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 6
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }