android-samples icon indicating copy to clipboard operation
android-samples copied to clipboard

ApiDemos:Uninitialized mapView in OnMapAndViewReadyListener will cause crash

Open newmanw opened this issue 4 years ago • 1 comments

Please be sure to include as much information as possible:

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...") ApiDemos

  2. OS type and version Android 7

  3. Library version and other environment information google_play_services_version '10.2.6'

Steps to reproduce

  1. Running on Android 7 w/ play services 10.2.6 com.google.android.gms.maps.SupportMapFragment.getView() is nullable. Frequently in this environment the view is NULL here:

https://github.com/googlemaps/android-samples/blob/816f8cc4241ec7c4eaf41b16f7fefcf10ae95faf/ApiDemos/kotlin/app/src/v3/java/com/example/kotlindemos/OnMapAndViewReadyListener.kt#L63

The follow if statement if mapView is NULL will evaluate to true, which will incorrectly setup 'isViewReady'

        if (mapView?.width != 0 && mapView?.height != 0) {
            // View has already completed layout.
            isViewReady = true
        }

Code should account for a null mapView to avoid crash.

newmanw avatar Apr 15 '21 19:04 newmanw

Thanks! Please feel free to send us a PR for this.

arriolac avatar Jul 13 '21 19:07 arriolac

The following PR fixes this issue.

kikoso avatar Nov 29 '22 16:11 kikoso

:tada: This issue has been resolved in version 1.6.4 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

googlemaps-bot avatar Dec 23 '22 12:12 googlemaps-bot