rules_android icon indicating copy to clipboard operation
rules_android copied to clipboard

Can't build example basicapp

Open pswaminathan opened this issue 10 months ago • 4 comments

Steps:

  1. Check out HEAD
  2. Go to examples/basicapp
  3. bazel build java/com/basicapp:basic_app

Output:

bazel build java/com/basicapp:basic_app
ERROR: /private/var/tmp/_bazel_p/55ff8364e78f780939b7116c861984c8/external/rules_android~/tools/android/BUILD:173:10: in sh_binary rule @@rules_android~//tools/android:desugar_java8: target '@@bazel_tools//src/tools/android/java/com/google/devtools/build/android/r8:desugar' is not visible from target '@@rules_android~//tools/android:desugar_java8'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /private/var/tmp/_bazel_p/55ff8364e78f780939b7116c861984c8/external/rules_android~/tools/android/BUILD:173:10: Analysis of target '@@rules_android~//tools/android:desugar_java8' failed
ERROR: Analysis of target '//java/com/basicapp:basic_app' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.142s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

pswaminathan avatar Mar 30 '24 15:03 pswaminathan

IIRC I fixed this upstream in bazelbuild/bazel a while ago, but it hasn't made it into a release yet. If you use a build of bazel close to head (as our README suggests), this should build correctly.

ted-xie avatar Apr 10 '24 19:04 ted-xie

Thanks @ted-xie ! That does indeed get me farther, but still a failure:

bazel build --verbose_failures java/com/basicapp:basic_app
Starting local Bazel server and connecting to it...
INFO: Analyzed target //java/com/basicapp:basic_app (330 packages loaded, 16043 targets configured).
ERROR: /Users/p/Code/bazel/rules_android/examples/basicapp/java/com/basicapp/BUILD:9:16: Compiling Android Resources in java/com/basicapp/_migrated/basic_lib_symbols/symbols.zip failed: (Exit 2): java failed: error executing CompileAndroidResources command (from target //java/com/basicapp:basic_lib)
  (cd /private/var/tmp/_bazel_p/55ff8364e78f780939b7116c861984c8/sandbox/darwin-sandbox/1/execroot/_main && \
  exec env - \
  external/rules_java~~toolchains~remotejdk11_macos_aarch64/bin/java -Xms4G -Xmx4G -XX:+ExitOnOutOfMemoryError -jar bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox_deploy.jar --tool COMPILE_LIBRARY_RESOURCES -- --aapt2 bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_android~~android_sdk_repository_extension~androidsdk/aapt2_binary --resources java/com/basicapp/res:::: --output bazel-out/darwin_arm64-fastbuild-android-ST-80dd4ae33d52/bin/java/com/basicapp/_migrated/basic_lib_symbols/symbols.zip --targetLabel //java/com/basicapp:basic_lib --manifest bazel-out/darwin_arm64-fastbuild-android-ST-80dd4ae33d52/bin/java/com/basicapp/_migrated/_min_sdk_bumped/basic_lib/AndroidManifest.xml --androidJar external/rules_android~~android_sdk_repository_extension~androidsdk/platforms/android-34/android.jar)
# Configuration: e0ee379e8deebddd77b721799537f6bcb4ec2a7c5aeb6e253cef82be0b0f4583
# Execution platform: @@platforms//host:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
Error parsing command line: Unrecognized option: --targetLabel
Try --help.
Target //java/com/basicapp:basic_app failed to build
INFO: Elapsed time: 5.983s, Critical Path: 0.42s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully

pswaminathan avatar Apr 20 '24 11:04 pswaminathan

I wasn't able to repro this -- the error is pretty surprising: Error parsing command line: Unrecognized option: --targetLabel. This is the code that creates that COMPILE_LIBRARY_RESOURCES action:

https://github.com/bazelbuild/rules_android/blob/25c784ba600db81b425c4ac5e12a7f5d60052e1d/rules/busybox.bzl#L672

and --targetLabel is not added there, and it doesn't look like it was there before. Are you using some local customizations?

ahumesky avatar Apr 22 '24 18:04 ahumesky

Whoops, turns out I do have some local customizations that I had forgotten about. I'll revert back to main and try again.

pswaminathan avatar Apr 26 '24 18:04 pswaminathan

Cool, thanks for letting us know. Feel free to re-open if you run into this again with an unmodified Bazel + unmodified rules_android.

ted-xie avatar Jul 24 '24 20:07 ted-xie