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>
136 lines
4.3 KiB
Kotlin
136 lines
4.3 KiB
Kotlin
import java.util.Properties
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.kotlin.android)
|
|
alias(libs.plugins.kotlin.compose)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
alias(libs.plugins.hilt.android)
|
|
alias(libs.plugins.ksp)
|
|
}
|
|
|
|
val localProperties = Properties().apply {
|
|
val file = rootProject.file("local.properties")
|
|
if (file.exists()) {
|
|
file.inputStream().use { load(it) }
|
|
}
|
|
}
|
|
|
|
fun localProp(key: String, default: String): String =
|
|
(localProperties.getProperty(key) ?: System.getenv(key) ?: default)
|
|
|
|
android {
|
|
namespace = "com.guidecity.app"
|
|
compileSdk = 34
|
|
|
|
defaultConfig {
|
|
applicationId = "com.guidecity.app"
|
|
minSdk = 26
|
|
targetSdk = 34
|
|
versionCode = 1
|
|
versionName = "0.1.0"
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
buildConfigField(
|
|
"String",
|
|
"DGIS_API_KEY",
|
|
"\"${localProp("DGIS_API_KEY", "")}\"",
|
|
)
|
|
buildConfigField(
|
|
"String",
|
|
"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 {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
freeCompilerArgs += listOf(
|
|
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
|
|
)
|
|
}
|
|
|
|
buildFeatures {
|
|
compose = true
|
|
buildConfig = true
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
// Production code calls android.util.Log for observability; without this,
|
|
// the Android stub jar throws on every such call in plain JVM unit tests.
|
|
isReturnDefaultValues = true
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
implementation(platform(libs.androidx.compose.bom))
|
|
implementation(libs.androidx.ui)
|
|
implementation(libs.androidx.ui.graphics)
|
|
implementation(libs.androidx.ui.tooling.preview)
|
|
implementation(libs.androidx.material3)
|
|
implementation(libs.androidx.material.icons.extended)
|
|
implementation(libs.androidx.navigation.compose)
|
|
debugImplementation(libs.androidx.ui.tooling)
|
|
|
|
implementation(libs.hilt.android)
|
|
ksp(libs.hilt.compiler)
|
|
implementation(libs.hilt.navigation.compose)
|
|
|
|
implementation(libs.retrofit.core)
|
|
implementation(libs.retrofit.kotlinx.serialization.converter)
|
|
implementation(libs.okhttp.logging.interceptor)
|
|
implementation(libs.kotlinx.serialization.json)
|
|
|
|
implementation(libs.androidx.room.runtime)
|
|
implementation(libs.androidx.room.ktx)
|
|
ksp(libs.androidx.room.compiler)
|
|
|
|
implementation(libs.androidx.datastore.preferences)
|
|
|
|
implementation(libs.play.services.location)
|
|
implementation(libs.kotlinx.coroutines.play.services)
|
|
|
|
// 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)
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
androidTestImplementation(libs.androidx.test.ext.junit)
|
|
androidTestImplementation(libs.androidx.espresso.core)
|
|
androidTestImplementation(platform(libs.androidx.compose.bom))
|
|
androidTestImplementation(libs.androidx.ui.test.junit4)
|
|
debugImplementation(libs.androidx.ui.test.manifest)
|
|
}
|