bazel: Android tool causing Desugar action to fail when building Android tools from source

Description of the problem / feature request:

When building Android Tools from the tip of Bazel 3.3.0 branch an error is thrown in Desugar worker log saying: Error parsing command line: Unrecognized option: --persistent_worker

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Build Android tools from source and try to build Android binary target using them

  1. Make sure you’re on latest 3.3.0 release branch
  2. bazel build //src:bazel-dev //tools/android/runtime_deps:android_tools
  3. mkdir -p /tmp/bazel_android_tools
  4. tar -xzvf bazel-bin/tools/android/runtime_deps/android_tools.tar.gz -C /tmp/bazel_android_tools
  5. link the local build of Bazel built in step #2
  6. build your app and supply a flag to use the locally built android tools ./bazelw build --override_repository=android_tools=/tmp/bazel_android_tools //apps/myApp:app

Also tried doing the same steps but with at SHA f3d1683fcb3c4a25c4c4b8251d00ddfa66f958ba from here: https://github.com/bazelbuild/bazel/commit/f3d1683fcb3c4a25c4c4b8251d00ddfa66f958ba#diff-6f653881793ed1c14a8c9d92a49705b1 Also with no luck, I get the same error.

What operating system are you running Bazel on?

Linux/Mac

What’s the output of bazel info release?

3.3.0

Have you found anything relevant by searching the web?

Any other information, logs, or outputs that you want to share?

ERROR: /Users/sachin/PersonalProjects/samples-bazel-android/app/src/main/java/com/xachin/playground/BUILD.bazel:3:19: Desugaring app/src/main/java/com/xachin/playground/playground-app_kt.jar for Android failed: Worker process did not return a WorkResponse:

---8<---8<--- Start of log, file at /private/var/tmp/_bazel_sachin/6af8cdc15b57945be280298fb5d977c4/bazel-workers/worker-2-Desugar.log ---8<---8<---
Error parsing command line: Unrecognized option: --persistent_worker
Try --help.
---8<---8<--- End of log ---8<---8<---
Target //app:app failed to build

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 27 (27 by maintainers)

Commits related to this issue

Most upvoted comments

Getting a different issue after this fix, see:

ERROR: /home/nk/Dev/android/foo/platform/BUILD.bazel:195:19: Desugaring platform/core.jar for Android failed (Exit 1): desugar_java8 failed: error executing command 
  (cd /home/nk/.cache/bazel/_bazel_nk/2007fbffc9ead87bb25ae587ecsdcc95/execroot/__main__ && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  bazel-out/host/bin/external/bazel_tools/tools/android/desugar_java8 @bazel-out/android-armeabi-v7a-fastbuild/bin/platform/core/_dx/core/core.jar_desugared.jar-0.params)
Execution platform: @local_config_platform//:host
java.lang.IllegalArgumentException: resource com/google/devtools/build/android/desugar/runtime/PrimitiveHashcode.class not found.
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:216)
	at com.google.common.io.Resources.getResource(Resources.java:195)
	at com.google.devtools.build.android.desugar.io.ResourceBasedClassFiles.lambda$getContent$0(ResourceBasedClassFiles.java:32)
	at com.google.devtools.build.android.desugar.io.FileContentProvider.get(FileContentProvider.java:102)
	at com.google.devtools.build.android.desugar.io.FileContentProvider.sink(FileContentProvider.java:143)
	at com.google.devtools.build.android.desugar.Desugar.lambda$copyRuntimeClasses$7(Desugar.java:449)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at com.google.devtools.build.android.desugar.Desugar.copyRuntimeClasses(Desugar.java:448)
	at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:366)
	at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:240)
	at com.google.devtools.build.android.desugar.Desugar.processRequest(Desugar.java:1008)
	at com.google.devtools.build.android.desugar.Desugar.runPersistentWorker(Desugar.java:968)
	at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:947)
Target //apps/myApp/foo:app failed to build
INFO: Elapsed time: 39.935s (0.67m), Critical Path: 38.49s (0.64m)
INFO: 230 processes: 3 linux-sandbox, 227 worker 

I see the issue. None of our tests cover the primitive type desugaring feature required by that missing desugar resource. Will submit a fix.

Thanks for the repro @nkoroste - mailed #11620.