Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes unhandled NullPointerException for styleOperations #2081

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

matejbart
Copy link
Contributor

If the json String of the MapStyleOptions is empty, then the result of Gson().fromJson(json, ...) will be null which currently leads to an unhandled NullPointerException as soon as styleOperations is accessed causing an application crash:

java.lang.NullPointerException: styleOperations must not be null
    at org.microg.gms.maps.mapbox.StylesKt.apply(Styles.kt:119)
    at org.microg.gms.maps.mapbox.StylesKt.getStyle(Styles.kt:79)
    at org.microg.gms.maps.mapbox.StylesKt.getStyle$default(Styles.kt:42)
    at org.microg.gms.maps.mapbox.GoogleMapImpl.applyMapStyle(GoogleMap.kt:385)
    at org.microg.gms.maps.mapbox.GoogleMapImpl.setMapType(GoogleMap.kt:371)

The crash doesn't occur on phones that use Google Play Services; therefore, the null check fixes the crash and aligns the API with the proprietary services.

Copy link
Contributor

@fynngodau fynngodau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙂

@mar-v-in mar-v-in merged commit c728424 into microg:master Dec 15, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants