fix: prevent Map tab crash on Android builds without a Google Maps key (#25)#26
Merged
Merged
Conversation
#25) Mounting react-native-maps' MapView on Android without a Google Maps API key crashes the native SDK (grey screen → crash). Every released build shipped an empty-value com.google.android.geo.API_KEY meta-data tag — itself a crash trigger — because prebuild ran with the env var unset. - app.config.ts: only emit the googleMaps key block when a key is actually present (never write an empty-string API key); expose a hasGoogleMapsKey flag via extra. - map.tsx: on Android without a key, render a fallback instead of mounting MapView, so the native map never initializes keyless. iOS is unaffected. - release.yml: inject EXPO_PUBLIC_GOOGLE_MAPS_API_KEY at prebuild so GitHub release builds get a working map. - docs: correct the inaccurate "blank tiles but markers still work" claim in README, F-Droid submission notes, and the F-Droid metadata.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #25 — the Map tab crashes on Android (grey screen → crash) for every released build.
Root cause:
react-native-maps'MapViewcrashes the native Google Maps SDK on Android when no API key is present. Worse,app.config.tsbaked an empty-valuecom.google.android.geo.API_KEYmeta-data tag into the manifest wheneverEXPO_PUBLIC_GOOGLE_MAPS_API_KEYwas unset — itself a known native crash trigger — and the release workflow ranexpo prebuildwith that env var unset, so every published APK shipped the crash.Changes
app.config.ts— only emit thegoogleMapskey block when a key is actually provided (never write an empty-string key); expose ahasGoogleMapsKeyflag viaextra.app/(tabs)/map.tsx— on Android without a key, render a "Map not available in this build" fallback instead of mountingMapView, so the native map never initializes keyless. iOS (Apple Maps) is unaffected..github/workflows/release.yml— injectEXPO_PUBLIC_GOOGLE_MAPS_API_KEYat prebuild so GitHub release builds get a working map.Why this is robust
Layer 2 makes it structurally impossible to mount the native map without a key, so the crashing code path is never reached on keyless builds — regardless of the exact native fault.
Action required after merge
Add the
EXPO_PUBLIC_GOOGLE_MAPS_API_KEYrepository secret. Without it, release builds show the fallback (no crash) rather than a real map.Caveat
Diagnosed from the report + code, not from a device repro/logcat. The fix is designed to hold even if the precise native cause differs, but the one scenario it wouldn't cover is a crash that also occurs with a valid key (a pure new-architecture/Fabric incompatibility). The symptom matches the keyless signature exactly, so this is considered unlikely.
Verification
pnpm typecheckandpnpm lintboth pass clean.