AndroidRuntime: FATAL EXCEPTION: androidmapsapi-ZoomTableManager

Prem Chand picture Prem Chand · Apr 23, 2020 · Viewed 11.3k times · Source

My app that uses Google Maps SDK (v2) just started crashing with this exception:

Process: com.currentlocation.android, PID: 7328
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=12
        at com.google.maps.api.android.lib6.gmm6.vector.ct.<init>(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (120400-0):9)
        at com.google.maps.api.android.lib6.gmm6.vector.cv.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (120400-0):23)
        at com.google.maps.api.android.lib6.gmm6.util.m.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (120400-0):14)
        at java.lang.Thread.run(Thread.java:919)

In the v3 beta SDK, the stack trace is:

2020-04-23 15:59:06.064 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example, PID: 22717
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=12
        at com.google.android.libraries.maps.bv.zzbs.<init>(ZoomTable.java:24)
        at com.google.android.libraries.maps.bv.zzbv.zza(ZoomTableQuadTree.java:57)
        at com.google.android.libraries.maps.br.zzd.zza(Unknown Source:4)
        at com.google.android.libraries.maps.hi.zzas.zza(Suppliers.java:7)
        at com.google.android.libraries.maps.br.zza.zzh(SharedMapComponentImpl.java:58)
        at com.google.android.libraries.maps.gu.zzat.zza(RendererFactoryImpl.java:88)
        at com.google.android.libraries.maps.it.zzav.zza(GoogleMapImpl.java:59)
        at com.google.android.libraries.maps.it.zzci.zza(MapFragmentDelegateImpl.java:3)
        at com.google.android.libraries.maps.it.zzcg.zza(MapFragmentDelegateImpl.java:15)
        at com.google.android.libraries.maps.SupportMapFragment$zza.onCreateView(SupportMapFragment.java:15)
        at com.google.android.gms.dynamic.zae.zaa(com.google.android.gms:play-services-base@@17.1.0:4)
        at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(com.google.android.gms:play-services-base@@17.1.0:9)
        at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreateView(com.google.android.gms:play-services-base@@17.1.0:25)
        at com.google.android.libraries.maps.SupportMapFragment.onCreateView(SupportMapFragment.java:34)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:310)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1185)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1354)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1432)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1495)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2617)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2722)
        at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:336)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1186)
        at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2222)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1995)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1951)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1847)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2621)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2722)
        at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:336)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1186)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1354)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1432)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1495)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2617)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1432)
        at android.app.Activity.performStart(Activity.java:7848)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
2020-04-23 15:59:06.064 E/AndroidRuntime:     at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        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)

What is the cause?

Answer

jon picture jon · Apr 23, 2020

Edit: following is the official solution from Google (link)

Summary

Google Maps SDK thread crashes App (ArrayIndexOutOfBoundsException) - Solution Offered

Description

On April 23 2020 starting at 11:30 PDT, Google served for 4 hours an update to the configuration of a Maps mobile component, triggering crashes in Maps SDKs for Android and iOS. Applications on devices that downloaded this version of the configuration (during the outage period) were vulnerable to the crash. Workaround solutions are offered for Maps SDKs for Android and iOS.

Maps SDK for Android

Maps SDK for Android v2 (included in Google Play Services)

The updates to Google Play Services to fix the crash has been published to all devices with Google Play Services version 17.4.55 and newer. There is no change to the version number of Google Play Services on the device after the update is installed. No action is required from developers or end users to receive the updated Maps module; however, developers can verify that the module is present on a given device with the following adb command:

adb shell dumpsys activity provider com.google.android.gms.chimera.container.GmsModuleProvider

You should see the line Module Set ID: maps listed in the Module Sets section.

Module Set ID: maps, Module Set Version: 2015120015120000

The crash rates of Maps SDK for Android v2 are back to normal.

As of now, if you have not updated your app with the client-side code workarounds mentioned below, you do not need to take further action.

If you have already updated your app with the workarounds, you can remove the workaround in a subsequent update of your app (but keeping the workaround is safe).

Premium Plan Maps SDK for Android v2 or Maps SDK for Android v3 beta (static libraries)

If your app uses the Premium Plan Maps SDK for Android v2 or Maps SDK for Android v3 beta (static libraries), and is still experiencing crashes, we still highly recommend you to roll out the workarounds below via an update to your app. As your application is loading a static version of the SDK which is vulnerable to the bad data being stored on some devices, only an update to your application can solve the problem.

Play Store review approvals

If you update your app but experience Play Store review approvals delays, please file a support case with your app’s Package ID: ⁠Contact the support team. Our Support Team will internally escalate your request and expedite the approval.

Negative reviews in the Google Play Store

Some application developers inquired about 1-star reviews in the Google Play Store left by end-users due to crashes. Only comments that violate Google Play's policy [ 1 ] can be removed. You can also flag abusive reviews in the Play Console [ 2 ]. Applications will not be automatically removed from the Google Play store due to negative reviews. It's also worth noting that the calculation of your overall app review rating favors recent reviews, which means that your rating will recover to pre-incident levels over time.

[ 1 ] ⁠Ratings & Review on the Play Store

[ 2 ] ⁠Report inappropriate reviews

Maps SDK for iOS

Crash rates on iOS are back to normal. If your application is still experiencing crashes, you need to update and publish your app with the code workarounds communicated here.

For questions about deploying or expediting your application in the Apple App Store, please contact Apple directly.


With this update, we are closing this issue. Thank you to everyone for your patience. Our team is performing an in-depth internal investigation of this incident; as soon as possible, we will publish our analysis (in approximately a week). In the meantime, if you have any questions, or are still experiencing problems, please ⁠file a support case.

Workarounds:

  • End users on Android can clear the affected app's data (not just the cache).

  • End users on iOS can uninstall then reinstall the affected app(s).

  • App Developers can apply the code workarounds below in order to solve the issue for all their end users.

Code workaround for iOS:

Recommended placement for the code is before GMSServices initialization in the application(_:didFinishLaunchingWithOptions:) (Swift) or application:didFinishLaunchingWithOptions: (Objective-C) method. Specifically:

Swift:

let key = "GoogleMapsServerControlledParamsKey_bug_154855417"
if !UserDefaults.standard.bool(forKey: key) {
    let urls = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)
    if urls.count > 0 {
        let paramUrl = urls[0].appendingPathComponent("com.google.GoogleMaps/ServerControlledParams", isDirectory: false)
        try? FileManager.default.removeItem(at: paramUrl)
    }
    UserDefaults.standard.set(true, forKey: key)
}

Objective-C:

NSString *key = @"GoogleMapsServerControlledParamsKey_bug_154855417";
BOOL keyExists = [[NSUserDefaults standardUserDefaults] boolForKey:key];
if (!keyExists) {
    NSArray<NSURL *> *array =
        [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory
                                               inDomains:NSUserDomainMask];
    if (array.count > 0) {
        NSURL *url =
            [array[0] URLByAppendingPathComponent:@"com.google.GoogleMaps/ServerControlledParams"
                                      isDirectory:NO];
        if (url) {
            [[NSFileManager defaultManager] removeItemAtURL:url error:NULL];
        }
    }
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
}

Code workaround for Android:

The recommended placement for the code is in Application.onCreate():

Java

try {
  SharedPreferences hasFixedGoogleBug154855417 = getSharedPreferences("google_bug_154855417", Context.MODE_PRIVATE);
  if (!hasFixedGoogleBug154855417.contains("fixed")) {
    File corruptedZoomTables = new File(getFilesDir(), "ZoomTables.data");
    File corruptedSavedClientParameters = new File(getFilesDir(), "SavedClientParameters.data.cs");
    File corruptedClientParametersData =
        new File(
          getFilesDir(),
          "DATA_ServerControlledParametersManager.data."
              + getBaseContext().getPackageName());
    File corruptedClientParametersDataV1 =
        new File(
          getFilesDir(),
          "DATA_ServerControlledParametersManager.data.v1."
              + getBaseContext().getPackageName());
    corruptedZoomTables.delete();
    corruptedSavedClientParameters.delete();
    corruptedClientParametersData.delete();
    corruptedClientParametersDataV1.delete();
    hasFixedGoogleBug154855417.edit().putBoolean("fixed", true).apply();
  }
} catch (Exception e) {

}

Kotlin

try {
    val sharedPreferences = getSharedPreferences("google_bug_154855417", Context.MODE_PRIVATE)
    if (!sharedPreferences.contains("fixed")) {
        val corruptedZoomTables = File(filesDir, "ZoomTables.data")
        val corruptedSavedClientParameters = File(filesDir, "SavedClientParameters.data.cs")
        val corruptedClientParametersData = File(filesDir, "DATA_ServerControlledParametersManager.data.${packageName}")
        val corruptedClientParametersDataV1 = File(filesDir, "DATA_ServerControlledParametersManager.data.v1.${packageName}")
        corruptedZoomTables.delete()
        corruptedSavedClientParameters.delete()
        corruptedClientParametersData.delete()
        corruptedClientParametersDataV1.delete()
        sharedPreferences.edit().putBoolean("fixed", true).apply()
    }
} catch (exception: Exception) {

}

The workarounds provided here covers all available flavors and versions of our SDKs for Android. To clarify further (in case you released an earlier version of the workaround that did not delete as many files):

  • Applications that use Maps Android SDK v2 should only need to delete one file: ZoomTables.data.
  • Applications that use Maps Android SDK v3 beta should only need to delete one file, either

    DATA_ServerControlledParametersManager.data.v1. + getBaseContext().getPackageName()) or

    DATA_ServerControlledParametersManager.data. + getBaseContext().getPackageName())