From 42c7f0d1731505aa85ecc4f68fdb1e68cd902397 Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Tue, 17 Aug 2021 16:20:29 +0100 Subject: [PATCH] Propagate dependencies from `android_library` to apps. Automatically add `uses_libs`/`optional_uses_libs` properties specified in `android_library` modules to the apps that transitively depend on these libraries. Note that a library may choose to specify its deps as either optional or required. If this is not the right choice for an app, it should be able to override it by specifying its own `uses_libs`/ `optional_uses_libs` properties. Bug: 196377222 Test: lunch aosp_cf_x86_64_phone-userdebug && m Change-Id: I1e36c56719c0023dcd25fa6aeb92016471702b9f --- java/aar.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/aar.go b/java/aar.go index 04727e4b9..afbaea23b 100644 --- a/java/aar.go +++ b/java/aar.go @@ -502,11 +502,12 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { if sdkDep.hasFrameworkLibs() { a.aapt.deps(ctx, sdkDep) } + a.usesLibrary.deps(ctx, sdkDep.hasFrameworkLibs()) } func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.aapt.isLibrary = true - a.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap) + a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts) a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()