Android Google Play Maps: Fatal Exception: java.lang.NoClassDefFoundError

May 17, 2019
Failed resolution of: Lorg/apache/http/ProtocolVersion;

I bump into the following error when upgrading compileSdkVersion/targetSdkVersion to 28 (from 27) while using implementation 'com.google.android.gms:play-services-maps15.0.1.

Fatal Exception: java.lang.NoClassDefFoundError
Failed resolution of: Lorg/apache/http/ProtocolVersion;

NOTE: The error didn't occur on Android Pie (API 28) emulator / Android Lollipop (API 21) Phone / Android Oreo (API 26 Phone). It happened on a Android Pie (API 28) Phone.

Based on this source:

If you are using com.google.android.gms:play-services-maps:16.0.0 or below and your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element of AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest ..>
    <uses-library
        android:name="org.apache.http.legacy"
        android:required="false" />
</manifest>

This is handled for you if you are using com.google.android.gms:play-services-maps:16.1.0 and is not necessary if your app is targeting a lower API level.

NOTE: I opt to use com.google.android.gms:play-services-maps:16.1.0 to solve problem instead.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.