Files
plezy/android/build.gradle.kts
T
edde746 8aa836d106 ci(android): gate name-based reachability on an R8-minified variant
R8 only ever ran on `release`, so every automated gate in this repository
exercised code the shipped APK does not contain. Reflective lookups, JNI
callbacks and native library loading can all break under shrinking while
`flutter test`, the Robolectric suites and `connectedDebugAndroidTest`
stay green — which is exactly how #1703 shipped, with the bundled FFmpeg
audio renderer shrunk out of release builds for TrueHD and DTS-HD.

Add a `minified` build type that inherits release's shrinker
configuration but stays debuggable and debug-signed, so it is an ordinary
test artifact and never a publishable one. Three integration details
took a run each to find: the Flutter plugin copies app build types into
every plugin module, so library-level shrinking deleted the plugin entry
points that only GeneratedPluginRegistrant references; the harness must
not be shrunk or the runner disappears; and androidx.test has to survive
in the app under test, or the runner cannot link its own supertype and
the run reports zero tests instead of failing.

Instrumentation still defaults to `debug`, because only one build type
can host androidTest and the existing playback suites drive media3
builder APIs the app never calls, which R8 shrinks legitimately. The new
reachability test opts into the minified variant instead and touches no
builder API, so the only keeps it depends on are the ones under test.
Emptying proguard-rules.pro was verified to fail it.
2026-07-28 20:13:40 +02:00

52 lines
2.1 KiB
Kotlin

import com.android.build.api.variant.LibraryAndroidComponentsExtension
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
subprojects {
plugins.withId("com.android.library") {
// This project still runs Flutter's legacy KGP mode. AGP 9-aware
// plugins such as file_picker may otherwise assume built-in Kotlin
// and leave their src/main/kotlin entry points uncompiled.
if (name == "file_picker" && !pluginManager.hasPlugin("org.jetbrains.kotlin.android")) {
pluginManager.apply("org.jetbrains.kotlin.android")
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
extensions.configure<LibraryAndroidComponentsExtension> {
finalizeDsl { extension ->
// Plugin modules can lag the app's Android tools even when
// their dependencies already require current APIs.
extension.compileSdk = 36
extension.buildToolsVersion = "36.1.0"
// The Flutter plugin copies the app's build types into every plugin
// module, so `minified` arrives here carrying the app's shrinker flags.
// Library-level shrinking then deletes the plugin entry points that only
// GeneratedPluginRegistrant references, and the app's R8 fails on the
// missing classes. Only the app should shrink.
extension.buildTypes.findByName("minified")?.isMinifyEnabled = false
}
}
}
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}