3

I'm trying to use google map v1, in my android app, but app crashes as soon as I open map activity in android 10.

*FATAL EXCEPTION: DataRequestDispatcher
Process: c.techahead.androidmapsv1, PID: 6646
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/HttpClient;
    at com.google.android.maps.MapActivity.<init>(MapActivity.java:356)
    at c.techahead.androidmapsv1.MainActivity.<init>(MainActivity.java:8)
    at java.lang.Class.newInstance(Native Method)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
    at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1250)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3182)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
   *

build.gradle

android {
    compileSdkVersion 28
    buildToolsVersion "25.0.2"
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        useLibrary 'org.apache.http.legacy'
    } 
    dependencies {
    provided files('libs/maps.jar')
     compile files('libs/org.apache.http.legacy.jar')
    compile files('libs/httpclient-4.0.3.jar')
}
Max Base
  • 639
  • 1
  • 7
  • 15

1 Answers1

1

Support for the Apache HTTP client was removed beginning with Android 9. What you need to do instead is add the following declaration:

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

within the <application> element of your AndroidManifest.xml.

Note that if you use (or update to) com.google.android.gms:play-services-maps:16.1.0 or above, then you don't need to add this at all. For more details check out Google's documentation.

Hope this helps!

evan
  • 5,443
  • 2
  • 11
  • 20
  • 1
    This seems not to suffice for Google Maps V1. `com.google.android.gms:play-services-maps:16.1.0` is Maps V2 with a different API – ge0rg Oct 16 '19 at 10:56
  • Sorry you are right, this is V1, not V2. Can you please share a link to your Maps SDK for Android V1 code, so that I can reproduce this from my side? Note that V1 was deprecated in 2013 so it's almost a miracle that it still works at all (in Android 9)! – evan Jan 29 '20 at 13:57