diff --git a/java/app.go b/java/app.go index 46ca96918..c24e0c56b 100755 --- a/java/app.go +++ b/java/app.go @@ -1962,8 +1962,9 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs if hasFrameworkLibs { // Dexpreopt needs paths to the dex jars of these libraries in order to construct // class loader context for dex2oat. Add them as a dependency with a special tag. - ctx.AddVariationDependencies(nil, usesLibTag, dexpreopt.CompatUsesLibs...) - ctx.AddVariationDependencies(nil, usesLibTag, dexpreopt.OptionalCompatUsesLibs...) + ctx.AddVariationDependencies(nil, usesLibCompat29Tag, dexpreopt.CompatUsesLibs29...) + ctx.AddVariationDependencies(nil, usesLibCompat28Tag, dexpreopt.OptionalCompatUsesLibs28...) + ctx.AddVariationDependencies(nil, usesLibCompat30Tag, dexpreopt.OptionalCompatUsesLibs30...) } } } @@ -1981,14 +1982,16 @@ func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) dexpreopt.Libr usesLibPaths := make(dexpreopt.LibraryPaths) if !ctx.Config().UnbundledBuild() { - ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) { - dep := ctx.OtherModuleName(m) - if lib, ok := m.(Dependency); ok { - usesLibPaths.AddLibraryPath(ctx, dep, lib.DexJarBuildPath(), lib.DexJarInstallPath()) - } else if ctx.Config().AllowMissingDependencies() { - ctx.AddMissingDependencies([]string{dep}) - } else { - ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep) + ctx.VisitDirectDeps(func(m android.Module) { + if _, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok { + dep := ctx.OtherModuleName(m) + if lib, ok := m.(Dependency); ok { + usesLibPaths.AddLibraryPath(ctx, dep, lib.DexJarBuildPath(), lib.DexJarInstallPath()) + } else if ctx.Config().AllowMissingDependencies() { + ctx.AddMissingDependencies([]string{dep}) + } else { + ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep) + } } }) } diff --git a/java/java.go b/java/java.go index a973bab39..4b48a15a0 100644 --- a/java/java.go +++ b/java/java.go @@ -547,6 +547,18 @@ type dependencyTag struct { name string } +type usesLibraryDependencyTag struct { + dependencyTag + sdkVersion int // SDK version in which the library appared as a standalone library. +} + +func makeUsesLibraryDependencyTag(sdkVersion int) usesLibraryDependencyTag { + return usesLibraryDependencyTag{ + dependencyTag: dependencyTag{name: fmt.Sprintf("uses-library-%d", sdkVersion)}, + sdkVersion: sdkVersion, + } +} + func IsJniDepTag(depTag blueprint.DependencyTag) bool { return depTag == jniLibTag } @@ -566,9 +578,12 @@ var ( proguardRaiseTag = dependencyTag{name: "proguard-raise"} certificateTag = dependencyTag{name: "certificate"} instrumentationForTag = dependencyTag{name: "instrumentation_for"} - usesLibTag = dependencyTag{name: "uses-library"} extraLintCheckTag = dependencyTag{name: "extra-lint-check"} jniLibTag = dependencyTag{name: "jnilib"} + usesLibTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion) + usesLibCompat28Tag = makeUsesLibraryDependencyTag(28) + usesLibCompat29Tag = makeUsesLibraryDependencyTag(29) + usesLibCompat30Tag = makeUsesLibraryDependencyTag(30) ) func IsLibDepTag(depTag blueprint.DependencyTag) bool {