Skip to content

Fall back to OpenStreetMap when the build has no Google Maps key - #243

Merged
parawanderer merged 3 commits into
parawanderer:mainfrom
alex-so-3:fix/osm-without-maps-key
Oct 13, 2026
Merged

parawanderer merged 3 commits into
parawanderer:mainfrom
alex-so-3:fix/osm-without-maps-key

Conversation

@alex-so-3

@alex-so-3 alex-so-3 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

A build without MAPS_API_KEY crashes when the map screen opens (a fork, or a local build without secrets.properties). CONTRIBUTING says the app builds without a key but the map will not load; in practice the app does not start.

When the build has no Maps key and Google Maps is the chosen provider, MapProviderFactory.effectiveProvider falls back to OpenStreetMap, which needs no key. The map screen and the history screen both use it. Builds with a key behave exactly as before, and AMap is untouched.

Verified: on a phone, a debug build without a key: the app starts and shows OSM on the map and in history. ./gradlew testAll and add_strings.py --check pass.

alex-so-3 and others added 2 commits September 28, 2026 01:39
The map screen threw at start without MAPS_API_KEY; OSM needs no key, so it now
stands in for Google in both the map and the history screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016xeHfDLMuUeusX9PEgNEmY
A debug build from CI without the repository secret gets maps_key_default_value, which the check did not recognise, so it still drew an empty Google map. The key decision is now a pure function with a JVM test, and MapsActivity's separate checkApiKey, which repeated it, is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@parawanderer

Copy link
Copy Markdown
Owner

Good change. Never had it outright crash myself for whatever reason from CI builds, likely because I just supplied an invalid key for the debug app instead of no key. Either way, the map would render as empty in that case which is annoying. Thanks for testing the no key path. Defaulting to OpenStreetMap is better in both cases (invalid key/no key).

I'll have a model pass to add tests and also make the CI default to OpenStreetMap instead of a Google map that doesn't render.

@parawanderer

parawanderer commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Pushed 8a49cad on top:

  • maps_key_default_value, which build-debug.yml writes when the repository secret is missing, now also falls back to OpenStreetMap. CI debug builds from forks drew an empty Google map with it.
  • The key decision is a pure providerFor(providerType, key) with a JVM test (MapProviderFactoryTest). The Context overload only reads the key.
  • An unset or unknown provider counts as Google, since that is what create() turns it into.
  • Removed MapsActivity.checkApiKey(), which repeated the same check, and used imports in place of fully qualified names.

Drafted by Claude Code, reviewed by @parawanderer

effectiveProvider(null, key) was ambiguous between the two, and the unit test did not compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@parawanderer
parawanderer deployed to Android Build October 13, 2026 10:10 — with GitHub Actions Active
@parawanderer
parawanderer deployed to Android Build October 13, 2026 10:10 — with GitHub Actions Active
@parawanderer
parawanderer merged commit 2f80dfe into parawanderer:main Oct 13, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Android Build — bba4aaf1 Deployed Oct 13, 2026 by parawanderer via build #317
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.

2 participants