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

@ -42,6 +42,14 @@ android {
"API_BASE_URL",
"\"${localProp("API_BASE_URL", "http://10.0.2.2:8000/")}\"",
)
// The 2GIS SDK ships native libs for every ABI, which balloons the APK
// (~19MB -> ~190MB unfiltered). Almost all real devices are arm64
// today, and this keeps debug builds small enough to send anywhere
// (e.g. under Telegram bot's 50MB upload limit).
ndk {
abiFilters += "arm64-v8a"
}
}
buildTypes {
@ -110,9 +118,12 @@ dependencies {
implementation(libs.play.services.location)
implementation(libs.kotlinx.coroutines.play.services)
// 2GIS MapKit SDK: add once the exact Maven coordinates/repository are
// confirmed from https://docs.2gis.com/ — see map/DgisMapView.kt for the
// isolated integration point in the meantime.
// 2GIS MapKit SDK. Requires a real dgissdk.key in app/src/main/assets/,
// obtained per-app from dev.2gis.com — see README for details. Without
// it, DgisSdkProvider's init fails gracefully and DgisMapView falls back
// to its placeholder rendering.
implementation(libs.dgis.sdk.map)
implementation(libs.dgis.compose.map)
testImplementation(libs.junit)
testImplementation(libs.mockk)