ext { junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2' androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1' androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5' androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1' } buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.7.2' } } rootProject.allprojects { repositories { google() mavenCentral() } } apply plugin: 'com.android.library' // Android dependencies def DEFAULT_COMPILE_SDK_VERSION = 35 def DEFAULT_TARGET_SDK_VERSION = 35 // Plugin dependencies def DEFAULT_PLAY_SERVICES_LOCATION_VERSION = "21.3.0" def DEFAULT_TSLOCATIONMANAGER_VERSION = "4.4.+" def DEFAULT_EVENTBUS_VERSION = "3.3.1" def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } // Guards against the missing-symbol crash that occurs when an app pins an `ext.tslocationmanagerVersion` // older than the SDK this plugin's bridge adapter was built against. Returns `minVersion` (with a // warning) when the pinned version's entire range is below it; otherwise returns the pin unchanged. // Dynamic pins are handled by comparing the pin's ceiling to the minimum's floor, so "4.2.+" is // overridden while "4.+"/"+" are respected. Drop-in identical across the four plugin SDKs. def ensureTSLocationManagerVersion(String configured, String minVersion) { def parse = { String v, boolean asCeiling -> def parts = (v ?: "").trim().tokenize(".") def out = [0, 0, 0] boolean wild = false for (int i = 0; i < 3; i++) { if (wild) { out[i] = asCeiling ? Integer.MAX_VALUE : 0; continue } def p = (i < parts.size()) ? parts[i] : null if (p != null && p.isInteger()) { out[i] = p as int } else if (p != null) { // "+" wildcard or qualifier wild = true out[i] = asCeiling ? Integer.MAX_VALUE : 0 } // missing trailing component stays 0 } return out } def c = parse(configured, true) // ceiling of the app's pin def f = parse(minVersion, false) // floor of the required minimum def cmp = (c[0] <=> f[0]) ?: (c[1] <=> f[1]) ?: (c[2] <=> f[2]) if (cmp < 0) { println("[tslocationmanager] ⚠️ ext.tslocationmanagerVersion '${configured}' is older than the '${minVersion}' required by this plugin release and has been overridden to '${minVersion}'. The native bridge adapter references symbols added in '${minVersion}'; an older SDK causes missing-symbol build failures / runtime crashes. Update or remove ext.tslocationmanagerVersion in your root build.gradle to silence this warning.") return minVersion } return configured } android { namespace "com.transistorsoft.bggeo.capacitor" if (project.android.hasProperty("namespace")) { namespace("com.transistorsoft.bggeo.capacitor") } compileSdk safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) defaultConfig { minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26 targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'proguard-rules.pro' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_21 targetCompatibility JavaVersion.VERSION_21 } } repositories { google() mavenCentral() } dependencies { def playServicesLocationVersion = safeExtGet('playServicesLocationVersion', DEFAULT_PLAY_SERVICES_LOCATION_VERSION) def tslocationmanagerVersion = ensureTSLocationManagerVersion(safeExtGet('tslocationmanagerVersion', DEFAULT_TSLOCATIONMANAGER_VERSION), DEFAULT_TSLOCATIONMANAGER_VERSION) def eventBusVersion = safeExtGet('eventBusVersion', DEFAULT_EVENTBUS_VERSION) implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(':capacitor-android') testImplementation "junit:junit:$junitVersion" androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion" def locationMajorVersion = playServicesLocationVersion.split('\\.')[0] as int if (locationMajorVersion >= 21) { api "com.transistorsoft:tslocationmanager:$tslocationmanagerVersion" } else { api "com.transistorsoft:tslocationmanager-gms20:$tslocationmanagerVersion" } api "org.greenrobot:eventbus:$eventBusVersion" }