Background location tracking

This commit is contained in:
2026-03-09 22:33:35 +08:00
parent 1e1c7d9552
commit ccc1c62262
10 changed files with 371 additions and 127 deletions
+41 -23
View File
@@ -2,6 +2,7 @@ import com.android.build.gradle.LibraryExtension
import org.gradle.api.tasks.Delete
import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
allprojects {
repositories {
@@ -20,6 +21,46 @@ subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
// Force compileSdk, Java 17, and Kotlin JVM target 17 on all library subprojects.
// Must use the `subprojects {}` block (not `subprojects.forEach`) so the
// afterEvaluate callback is registered *before* evaluationDependsOn triggers.
subprojects {
afterEvaluate {
plugins.withId("com.android.library") {
val androidExt = extensions.findByName("android") as? BaseExtension
if (androidExt != null) {
try {
androidExt.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
androidExt.compileOptions.targetCompatibility = JavaVersion.VERSION_17
} catch (_: Throwable) {}
try {
val sdkNum = androidExt.compileSdkVersion?.removePrefix("android-")?.toIntOrNull() ?: 0
if (sdkNum < 36) {
androidExt.compileSdkVersion("android-36")
}
} catch (_: Throwable) {}
}
// Align Kotlin JVM target with Java 17 to avoid mismatch errors
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}
}
plugins.withId("com.android.application") {
val androidExt = extensions.findByName("android") as? BaseExtension
if (androidExt != null) {
try {
androidExt.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
androidExt.compileOptions.targetCompatibility = JavaVersion.VERSION_17
} catch (_: Throwable) {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}
}
}
}
subprojects {
project.evaluationDependsOn(":app")
}
@@ -46,29 +87,6 @@ subprojects.forEach { project ->
}
// Ensure Kotlin JVM target matches Java compatibility to avoid mismatches in third-party modules.
// Align Java compile options to Java 17 for Android modules so Kotlin JVM target mismatch is avoided.
subprojects.forEach { project ->
project.plugins.withId("com.android.library") {
val androidExt = project.extensions.findByName("android") as? BaseExtension
if (androidExt != null) {
try {
androidExt.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
androidExt.compileOptions.targetCompatibility = JavaVersion.VERSION_17
} catch (_: Throwable) {}
}
}
project.plugins.withId("com.android.application") {
val androidExt = project.extensions.findByName("android") as? BaseExtension
if (androidExt != null) {
try {
androidExt.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
androidExt.compileOptions.targetCompatibility = JavaVersion.VERSION_17
} catch (_: Throwable) {}
}
}
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}