Replace 2GIS MapKit with OpenStreetMap (osmdroid) — no key needed
Getting a working mobile-SDK key from 2GIS turned out to require a sales-mediated B2B process (Platform Manager subscription, demo keys explicitly excluded from mobile SDK use per their own docs), not a quick self-serve signup. Swapped to osmdroid instead: free, no API key or account, works immediately. CityMapView (replacing DgisMapView/DgisSdkProvider) wraps osmdroid's View-based MapView via AndroidView, forwarding lifecycle events, with markers for the user's location and each nearby place. Configured required OSM tile-usage-policy user agent + app-private tile cache in GuideCityApp. Removed the now-unused DGIS_API_KEY plumbing and the arm64-only ABI filter (osmdroid has no heavy native libs, so it's not needed) — APK is back down to ~19.6MB from ~69MB. Verified: testDebugUnitTest passes, assembleDebug produces a working APK, sent via the Telegram bot (previously blocked by its 50MB limit with the 2GIS build). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
7c4d5727e4
commit
37edc96d50
12 changed files with 147 additions and 220 deletions
43
README.md
43
README.md
|
|
@ -9,7 +9,7 @@ voice while showing a swipeable card stack. Starting city: Moscow.
|
|||
```
|
||||
┌────────────────────┐
|
||||
│ Android app │ Kotlin + Jetpack Compose
|
||||
│ (android/) │ 2GIS map, on-device TTS,
|
||||
│ (android/) │ OSM map, on-device TTS,
|
||||
└─────────┬──────────┘ location, Room favorites
|
||||
│ HTTPS / REST (JSON)
|
||||
┌─────────▼──────────┐
|
||||
|
|
@ -25,7 +25,7 @@ voice while showing a swipeable card stack. Starting city: Moscow.
|
|||
- `backend/` — FastAPI service exposing city/place/nearby-search endpoints,
|
||||
backed by PostgreSQL+PostGIS. See `backend/` for details.
|
||||
- `android/` — Kotlin/Compose app skeleton (MVVM, Hilt, Retrofit, Room,
|
||||
DataStore, 2GIS MapKit, on-device TextToSpeech).
|
||||
DataStore, OpenStreetMap via osmdroid, on-device TextToSpeech).
|
||||
|
||||
## Backend quickstart
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ which works from anywhere (not just the local network) and is the preferred
|
|||
|
||||
```bash
|
||||
cp android/local.properties.example android/local.properties
|
||||
# fill in sdk.dir and DGIS_API_KEY (test key: b4df01a8-61db-4cb9-8286-7e069495987d)
|
||||
# fill in sdk.dir (and API_BASE_URL if not using the default)
|
||||
cd android && ./gradlew :app:assembleDebug
|
||||
```
|
||||
|
||||
|
|
@ -68,39 +68,18 @@ Wi-Fi/LAN.
|
|||
Run unit tests before building — `./gradlew testDebugUnitTest`, then
|
||||
`./gradlew :app:assembleDebug`.
|
||||
|
||||
## 2GIS map SDK
|
||||
## Map
|
||||
|
||||
The app depends on the real 2GIS MapKit SDK (`ru.dgis.sdk:sdk-map` +
|
||||
`compose-map`, from `https://artifactory.2gis.dev/sdk-maven-release`, wired
|
||||
up in `settings.gradle.kts`/`app/build.gradle.kts`). It needs a **separate**
|
||||
key from the `DGIS_API_KEY` above:
|
||||
|
||||
- `DGIS_API_KEY` (the `b4df01a...` value) is a 2GIS **public REST/JS API**
|
||||
key — not used by the native SDK at all currently.
|
||||
- The native MapKit SDK instead needs a **`dgissdk.key` file**, issued
|
||||
per-app (tied to the package name `com.guidecity.app`) from
|
||||
https://dev.2gis.com/. Place it at `android/app/src/main/assets/dgissdk.key`
|
||||
(gitignored — don't commit it).
|
||||
|
||||
Without that key file, `DgisSdkProvider` fails to initialize (logged, not
|
||||
crashed) and `DgisMapView` falls back to a placeholder canvas rendering
|
||||
(user location + nearby place dots, no real map tiles). Once a real key is
|
||||
in place, the real map should render automatically — no code changes needed.
|
||||
|
||||
Also note: the SDK bundles native libraries per CPU architecture, which
|
||||
balloons APK size a lot (~19MB → ~190MB unfiltered). `app/build.gradle.kts`
|
||||
restricts `ndk.abiFilters` to `arm64-v8a` only (~69MB) since that covers
|
||||
virtually all real devices today — remove that filter if you need to test
|
||||
on an x86 emulator or 32-bit device.
|
||||
Uses OpenStreetMap tiles via [osmdroid](https://github.com/osmdroid/osmdroid)
|
||||
(`map/CityMapView.kt`) — free, no API key or account needed, works out of
|
||||
the box. (An earlier iteration tried the native 2GIS MapKit SDK instead;
|
||||
dropped because getting a working mobile-SDK key from 2GIS turned out to be
|
||||
a sales-mediated B2B process, not a quick self-serve signup — see git
|
||||
history if that's ever worth revisiting.)
|
||||
|
||||
## Notes / current scope
|
||||
|
||||
This is iteration 1: Moscow only (Gorky Park, Red Square area, Moscow-City),
|
||||
no user accounts (favorites are local/Room-only), no speed/heading-aware
|
||||
auto content-length selection yet (reserved API params exist, unused).
|
||||
Nearby-search radius caps at 10km. Place markers aren't yet plotted on the
|
||||
real 2GIS map (only the placeholder does that) — follow-up work.
|
||||
|
||||
The 2GIS REST/JS API key above is used directly via
|
||||
`local.properties`/`BuildConfig` for development convenience — don't ship it
|
||||
as-is in a public repo. Same goes for `dgissdk.key` once you have one.
|
||||
Nearby-search radius caps at 10km.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue