From 7f60def767cad6006fc0fa2be06c57b5efdea301 Mon Sep 17 00:00:00 2001 From: Zhaoqing Xu Date: Wed, 20 Sep 2023 10:19:09 -0700 Subject: [PATCH] Only replace shrunk resource apk and optimized resource apk with non-null artifacts provided by AndroidOptimizationInfo from Starlark. PiperOrigin-RevId: 567004129 Change-Id: I977c9443d08297f365ada2fba870ca2cc5809928 --- .../devtools/build/lib/rules/android/AndroidBinary.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java index cb7e0d33ec0a34..c79871a676b6d6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java @@ -640,7 +640,11 @@ public static RuleConfiguredTargetBuilder createAndroidBinary( optimizationInfo.getConfig(), optimizationInfo.getRewrittenStartupProfile(), optimizationInfo.getRewrittenMergedBaselineProfile()); - resourceApk = resourceApk.withApk(optimizationInfo.getOptimizedResourceApk()); + if (optimizationInfo.getOptimizedResourceApk() != null) { + resourceApk = resourceApk.withApk(optimizationInfo.getOptimizedResourceApk()); + } else if (optimizationInfo.getShrunkResourceApk() != null) { + resourceApk = resourceApk.withApk(optimizationInfo.getShrunkResourceApk()); + } symlinkOptimizationOutputs( ruleContext, androidSemantics,