4

Google Maps v1 is not working on Android 10. Getting the following crash:

Process: com.xxx.xxx, PID: 12516
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/HttpClient;
    at com.google.android.maps.MapActivity.<init>(MapActivity.java:356)
    at com.xxx.view.MapMenuActivity.<init>(MapMenuActivity.java:34)
    at com.xxx.view.branches.BranchesMapActivity.<init>(BranchesMapActivity.java:28)
    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:1243)
    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)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
 Caused by: java.lang.ClassNotFoundException: org.apache.http.client.HttpClient
    at com.google.android.maps.MapActivity.<init>(MapActivity.java:356) 
    at com.xxx.view.MapMenuActivity.<init>(MapMenuActivity.java:34) 
    at com.xxx.view.branches.BranchesMapActivity.<init>(BranchesMapActivity.java:28) 
    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:1243) 
    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) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
    at android.os.Handler.dispatchMessage(Handler.java:107) 
    at android.os.Looper.loop(Looper.java:214) 
    at android.app.ActivityThread.main(ActivityThread.java:7356) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

gradle file includes the following dependencies and configs:

 buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'

    }
}

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    jcenter()
    google()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}

android {
    defaultConfig {
        versionName '4.1'
        versionCode 701   
    }

    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 28
        multiDexEnabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    useLibrary 'org.apache.http.legacy'
}

dependencies {

    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support:multidex:1.0.3'

    implementation files('libs/FlurryAnalytics-5.5.0.jar')
    implementation files('libs/libGoogleAnalyticsServices.jar')
    implementation files('libs/maps.jar')

    implementation 'com.mcxiaoke.volley:library:1.0.+'
    implementation 'com.neovisionaries:nv-i18n:1.+'
    implementation 'com.google.android.gms:play-services:12.0.1'

    implementation fileTree(dir: 'gradle/wrapper', include: ['*.aar', '*.jar'], exclude: [])
    implementation 'org.apache.httpcomponents:httpcore:4.4.11'
}

I have already added the following which makes it work till Android 9.0

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

I have looked into java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion, HttpClient won't import in Android Studio, Google maps v1 crashing in android 10 But these resources are working fine for Android 9.0, not for Android 10

Is there any solution to make Android 10 work with Google Maps v1?

Nav
  • 435
  • 1
  • 4
  • 15

0 Answers0