java_sdk_library use prebuilt jars for numeric sdk_version
Previously, when a library that used a numeric sdk version also
referenced a java_sdk_library it would use the current version of its
API. That was dangerous as there is an expectation that an app building
against a numbered version will also be targeted at that version and
so building against a later version of the API could hide runtime
incompatibilities.
This change will use prebuilt versions of the java_sdk_library's api
when being built for a numbered sdk version.
Bug: 148080325
Test: m droid
Change-Id: I3fd416553950785a443c1702e495a96debc33331
diff --git a/java/sdk_library.go b/java/sdk_library.go
index cd22e6e..fb8ae95 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -683,8 +683,9 @@
sdkVersion sdkSpec,
headerJars bool) android.Paths {
- // This module is just a wrapper for the stubs.
- if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
+ // If a specific numeric version has been requested or the build is explicitly configured
+ // for it then use prebuilt versions of the sdk.
+ if sdkVersion.version.isNumbered() || ctx.Config().UnbundledBuildUsePrebuiltSdks() {
return module.PrebuiltJars(ctx, sdkVersion)
} else {
if !sdkVersion.specified() {