Don't add dexpreopt compat deps to android_library modules
android_library modules are only dexpreopted when built into an app,
and the app will already get the dexpreopt compat dependencies itself.
Adding the compat dependencies to android_library modules causes
circular dependencies when the android_library is used to build
part of the framework, which is then used to build the compat libraries,
which is added as a dependency to the andorid_library.
Test: TestUsesLibraries
Change-Id: I3aca780858c7e5f19d270bcbbe18e6cff8616b43
diff --git a/java/app.go b/java/app.go
index eb1b474..df6698d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1295,14 +1295,14 @@
}
}
-func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
+func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps bool) {
if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs...)
ctx.AddVariationDependencies(nil, usesLibOptTag, u.presentOptionalUsesLibs(ctx)...)
- // Only add these extra dependencies if the module depends on framework libs. This avoids
- // creating a cyclic dependency:
+ // Only add these extra dependencies if the module is an app that depends on framework
+ // libs. This avoids creating a cyclic dependency:
// e.g. framework-res -> org.apache.http.legacy -> ... -> framework-res.
- if hasFrameworkLibs {
+ if addCompatDeps {
// 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, usesLibCompat29ReqTag, dexpreopt.CompatUsesLibs29...)