diff --git a/apex/apex_test.go b/apex/apex_test.go index 88da21bdc..1b689c5f9 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -1695,6 +1695,36 @@ func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) { expectNoLink("libx", "shared_apex10000", "libz", "shared") } +func TestApexMinSdkVersion_SupportsCodeNames_JavaLibs(t *testing.T) { + testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + java_libs: ["libx"], + min_sdk_version: "S", + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + java_library { + name: "libx", + srcs: ["a.java"], + apex_available: [ "myapex" ], + sdk_version: "current", + min_sdk_version: "S", // should be okay + } + `, + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.Platform_version_active_codenames = []string{"S"} + variables.Platform_sdk_codename = proptools.StringPtr("S") + }), + ) +} + func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) { ctx := testApex(t, ` apex { diff --git a/java/base.go b/java/base.go index b66b89071..a251c3f3e 100644 --- a/java/base.go +++ b/java/base.go @@ -1513,12 +1513,8 @@ func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, if sdkSpec.Kind == android.SdkCore { return nil } - ver, err := sdkSpec.EffectiveVersion(ctx) - if err != nil { - return err - } - if ver.GreaterThan(sdkVersion) { - return fmt.Errorf("newer SDK(%v)", ver) + if sdkSpec.ApiLevel.GreaterThan(sdkVersion) { + return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel) } return nil } diff --git a/java/java.go b/java/java.go index 71c1b3324..be1ad874f 100644 --- a/java/java.go +++ b/java/java.go @@ -1416,12 +1416,8 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, if sdkSpec.Kind == android.SdkCore { return nil } - ver, err := sdkSpec.EffectiveVersion(ctx) - if err != nil { - return err - } - if ver.GreaterThan(sdkVersion) { - return fmt.Errorf("newer SDK(%v)", ver) + if sdkSpec.ApiLevel.GreaterThan(sdkVersion) { + return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel) } return nil }