bazelbuild / bazelbuild/rules_android
[pre-release] Statically linking fails with custom styles that depend on resources in an aar
- Dominant language
- Java
- Stars
- 203
- Forks
- 95
- PR merge metrics
- No merged PRs in 30d
Description
We did another round of testing against the data bindings patches with the alpha branch of rules_android. We got further but hit a new failure case where custom styles that references Android resource attributes provided by 3rd party dependencies aren't being found during static linking.
Tested using `rules_jvm_external` and `bazel` HEAD.
Original report: https://github.com/bazelbuild/bazel/issues/11497#issuecomment-890020167
```
Exception in thread "main" java.lang.RuntimeException: Error during Statically linking com.google.devtools.build.android.aapt2.CompiledResources@35aea049:
Command: bazel-out/host/bin/external/androidsdk/aapt2_binary\
link\
--static-lib\
--manifest\
/var/folders/ts/25b588x11_n7f1k_2361ybr80000gp/T/android_resources_tmp17478694338343542457/manifest-aapt-dummy/AndroidManifest.xml\
--no-static-lib-packages\
--no-version-vectors\
-R\
/var/folders/ts/25b588x11_n7f1k_2361ybr80000gp/T/android_resources_tmp17478694338343542457/filtered/bazel-out/darwin-fastbuild/bin/_migrated/lib_symbols/symbols.zip\
-I\
external/androidsdk/platforms/android-30/android.jar\
--auto-add-overlay\
-o\
/var/folders/ts/25b588x11_n7f1k_2361ybr80000gp/T/android_resources_tmp17478694338343542457/lib.apk\
--java\
/var/folders/ts/25b588x11_n7f1k_2361ybr80000gp/T/android_resources_tmp17478694338343542457/java\
--output-text-symbols\
/var/folders/ts/25b588x11_n7f1k_2361ybr80000gp/T/android_resources_tmp17478694338343542457/R.txt
Output:
res/values/styles.xml:5: error: style attribute 'attr/autoSizeMinTextSize (aka com.demo.app:attr/autoSizeMinTextSize)' not found.
error: failed linking references.
at com.google.devtools.build.android.CommandHelper.execute(CommandHelper.java:42)
at com.google.devtools.build.android.AaptCommandBuilder.execute(AaptCommandBuilder.java:297)
at com.google.devtools.build.android.aapt2.ResourceLinker.linkStatically(ResourceLinker.java:272)
at com.google.devtools.build.android.ValidateAndLinkResourcesAction.main(ValidateAndLinkResourcesAction.java:207)
at com.google.devtools.build.android.ResourceProcessorBusyBox$Tool$7.call(ResourceProcessorBusyBox.java:105)
at com.google.devtools.build.android.ResourceProcessorBusyBox.processRequest(ResourceProcessorBusyBox.java:234)
at com.google.devtools.build.android.ResourceProcessorBusyBox.main(ResourceProcessorBusyBox.java:177)
Target //:lib failed to build
```
`BUILD`
```
load("@rules_android//rules:rules.bzl", "android_library")
android_library(
name = "lib",
custom_package = "com.demo.app",
# ... manifest, visibility, ...
resource_files = glob(["res/**/*.xml"]),
deps = [
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_appcompat_appcompat_resources",
],
)
```
`res/values/styles.xml`
```
<item name="autoSizeMinTextSize">1sp</item>
```
Contributor guide
Assessment
This issue has not been assessed yet.