Provide platform build flag to R8/D8
Provide the `--android-platform-build` flag to R8/D8 for targets that do
not specify a stable min SDK. This includes all targets that do not
specificy an SDK version (e.g., services.jar, SystemUI.apk) and all
targets that specify core_platform (e.g., framework.jar).
Follow-up work will expand the set of cases that qualify for this flag,
but for now this captures some of the highest priority targets.
Bug: 232073181
Test: m + presubmit + validate verbose.log
Change-Id: Idad32c80490a101c049b7f937807a615564ca8ef
diff --git a/java/dex.go b/java/dex.go
index a44d792..2b78703 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -200,6 +200,16 @@
"--verbose")
}
+ // Supplying the platform build flag disables various features like API modeling and desugaring.
+ // For targets with a stable min SDK version (i.e., when the min SDK is both explicitly specified
+ // and managed+versioned), we suppress this flag to ensure portability.
+ // Note: Targets with a min SDK kind of core_platform (e.g., framework.jar) or unspecified (e.g.,
+ // services.jar), are not classified as stable, which is WAI.
+ // TODO(b/232073181): Expand to additional min SDK cases after validation.
+ if !minSdkVersion.Stable() {
+ flags = append(flags, "--android-platform-build")
+ }
+
effectiveVersion, err := minSdkVersion.EffectiveVersion(ctx)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "%s", err)