Wire up the real 2GIS MapKit SDK (was a placeholder)

Added the actual ru.dgis.sdk:sdk-map + compose-map dependencies (from
https://artifactory.2gis.dev/sdk-maven-release) instead of the Canvas
placeholder guess. Verified the exact API surface by downloading the
AARs directly and inspecting classes with javap (DGis.initialize,
MapOptions, MapComposableState/MapComposable, CameraPosition/GeoPoint)
rather than relying on possibly-stale docs.

DgisSdkProvider lazily calls DGis.initialize() once per process,
catching failure so a missing key doesn't crash the app; DgisMapView
renders the real MapComposable when that succeeds, falling back to
the old placeholder canvas otherwise.

Important finding: the existing DGIS_API_KEY (2GIS's public REST/JS
API key format) does NOT work with this native SDK. It requires a
separate dgissdk.key file issued per-app-package from dev.2gis.com,
placed in app/src/main/assets/ (gitignored). Documented in README.
Without it the app still runs fine on the placeholder map.

Also restricted ndk.abiFilters to arm64-v8a — the SDK's native libs
otherwise balloon the APK from ~19MB to ~190MB.

Verified: testDebugUnitTest passes, assembleDebug produces a working
(arm64-only, ~69MB) APK. Not runtime-verified against a real map key
or device — no emulator/device available in this environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-07-09 21:28:52 +00:00
parent 7f1a6d51fc
commit 7c4d5727e4
9 changed files with 134 additions and 20 deletions

View file

@ -68,11 +68,39 @@ Wi-Fi/LAN.
Run unit tests before building — `./gradlew testDebugUnitTest`, then
`./gradlew :app:assembleDebug`.
## 2GIS map SDK
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.
## 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 API key above is used directly via `local.properties`/`BuildConfig`
for development convenience — don't ship it as-is in a public repo.
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.