question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes on bottom nav due to a fix on version 2.7.2 mapView.onDestroy(), mapView.removeAllViews()

See original GitHub issue

Environment details

  1. com.google.maps.android:maps-compose:2.7.2

Steps to reproduce

  1. Clone this repo
  2. add your google api key to the manifest file
  3. Build the app
  4. Quickly navigate between the bottom tabs and check if the app will crash or not
  5. The app crashes big time

Sample Video

  1. https://streamable.com/cbtdhq

Stack trace

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.googlemapsbottomnav, PID: 3421
    java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.z()' on a null object reference
        at com.google.maps.api.android.lib6.impl.cv.l(:com.google.android.gms.dynamite_mapsdynamite@223017067@22.30.17 (100408-0):0)
        at com.google.android.gms.maps.internal.q.ba(:com.google.android.gms.dynamite_mapsdynamite@223017067@22.30.17 (100408-0):2)
        at et.onTransact(:com.google.android.gms.dynamite_mapsdynamite@223017067@22.30.17 (100408-0):4)

Observation

The app will not crash when it use the com.google.maps.android:maps-compose:2.7.0 version

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
polivmi1commented, Sep 23, 2022

@thekingrenz23 I see that you are using nested navigation for each screen composable, which is causing the problem.

If you use this I am not able to reproduce:

AnimatedNavHost(
            navController = navController,
            startDestination = Screen.Other.route
        ) {
                composable(
                    route = Screen.Map.route
                ) {
                    MapRoute()
                }
                composable(
                    route = Screen.Other.route
                ) {
                    OtherRoute()
            }
}

The crash does happen during onStart and will be most likely related to caching. I can dig more later.

3reactions
polivmi1commented, Sep 30, 2022

@thekingrenz23 I hope that you can stay on the older version for a while unless we resolve this. I am trying to help and look at this, but I am also working, so I don’t have that much free time. @wangela would you be able to see where exactly in the obfuscated google maps code this is crashing? It does so during the start, so there must be some lifecycle caching during nested navigation and when switching navigation and destroying the view, google maps internally thinks something is still available. It could also be some race condition when it is destroyed and started again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MapView by Here crashes when calling mapView.onCreate in ...
In the first fragment, I initialize the map in onViewCreated and destroy it in onDestroyView. override fun onViewCreated(view: View, ...
Read more >
app crash on iOS 16.1(beta) when u… - Apple Developer
It can fix this problem. I found it's Apple's bug because the new Navigation Title in iOS 16 is TitleControl Class. When you...
Read more >
Solved: Arlo app crashes when mode is selected - Page 2
The new version solve some problems but give us at least one new: It crash everytime I try to press the mode tap....
Read more >
Guide - HERE SDK for Android (Explore Edition)
This guide walks you through the first steps to build apps with the HERE SDK. ... In such a case, you do not...
Read more >
Issues - android-maps-compose - Google Maps - Repos
App crashes on bottom nav due to a fix on version 2.7.2 mapView.onDestroy(), mapView.removeAllViews(). #207 opened 14 days ago by thekingrenz23.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found