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

AndroidGoogle MapsGoogle Play-Services

Android Problem Overview


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(: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):3at ek.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):4at em.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):51at com.google.maps.api.android.lib6.drd.ap.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):11at dw.a(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):16at dw.run(:com.google.android.gms.dynamite_mapsdynamite@12848063@12.8.48 (100408-196123505):61

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

This will resolve your crash. Apply this in manifest

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

<application/>

Solution 3 - Android

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" />

Solution 4 - Android

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" />

Solution 5 - Android

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

Solution 6 - Android

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"/>

Solution 7 - Android

Set tis:

multiDexEnabled true

Like this:

android {
    compileSdkVersion 28
    defaultConfig {

        multiDexEnabled true

    }
    buildTypes {
        release {
            
        }
    }
}

Solution 8 - Android

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'
    }

Solution 9 - Android

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.

Solution 10 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRamprasadView Question on Stackoverflow
Solution 1 - AndroidhamView Answer on Stackoverflow
Solution 2 - AndroidNickyView Answer on Stackoverflow
Solution 3 - AndroidDarushView Answer on Stackoverflow
Solution 4 - AndroidSumanView Answer on Stackoverflow
Solution 5 - AndroidcreativecoderView Answer on Stackoverflow
Solution 6 - AndroidAbdul Basit RishiView Answer on Stackoverflow
Solution 7 - Androidreza_khalafiView Answer on Stackoverflow
Solution 8 - AndroidSudhir SinghView Answer on Stackoverflow
Solution 9 - AndroidMina RogerView Answer on Stackoverflow
Solution 10 - AndroidumiView Answer on Stackoverflow