Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android platforms breaks incremental dexing and desugaring #230

Open
Bencodes opened this issue May 7, 2024 · 1 comment
Open

Android platforms breaks incremental dexing and desugaring #230

Bencodes opened this issue May 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Bencodes
Copy link
Contributor

Bencodes commented May 7, 2024

Steps to reproduce:

  1. Check out this branch https://github.com/bazelbuild/rules_android/compare/main...Bencodes:rules_android:platform-dex-desguar-bug?expand=1
  2. cd into examples/basicapp/
  3. Build using multiple Android platform targets USE_BAZEL_VERSION=last_green bazel build //... --android_platforms=@rules_android//:armeabi-v7a,@rules_android//:arm64-v8a --enable_bzlmod=true

The above will produce the following error:

Error in fail: Dependencies on .jar artifacts are not allowed in Android binaries, please use a java_import to depend on apps/rider/libsrc_devDebug.jar. If this is an implicit dependency then the rule that introduces it will need to be fixed to account for it correctly.

I did some debugging to try to narrow this one down. It seems that the transitions are correctly being applied when the aspect executes, but when the Android binary calls into _to_dexed_classpath it fails to find the accompanying aspect outputs for the given transition.

@ahumesky ahumesky added the bug Something isn't working label May 7, 2024
@ahumesky ahumesky self-assigned this May 15, 2024
@ahumesky
Copy link
Collaborator

Yes it looks like one part of the code is looking through jars from one configuration, and trying to look up those same jars in a dict formed from jars in a another configuration.

In this code specifically:

rules_android/rules/dex.bzl

Lines 386 to 392 in bb7b5cf

for jar in classpath:
if jar not in dex_archives_dict:
if jar not in runtime_jars_dict:
fail("Dependencies on .jar artifacts are not allowed in Android binaries, please use " +
"a java_import to depend on " + jar.short_path +
". If this is an implicit dependency then the rule that " +
"introduces it will need to be fixed to account for it correctly.")

with the above repro the jar is bazel-out/k8-fastbuild-android-ST-a9ac79439181/bin/java/com/basicapp/libbasic_lib.jar and dex_archives_dict contains

bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/libbasic_lib.jar -> bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_dx/basic_lib/libbasic_lib.jar.dex.zip
bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_migrated/basic_lib_resources.jar -> bazel-out/k8-fastbuild-android-ST-9b738726d3a8/bin/java/com/basicapp/_dx/basic_lib/basic_lib_resources.jar.dex.zip

even though libbasic_lib.jar is in the dict, it's from a different configuration (k8-fastbuild-android-ST-a9ac79439181, k8-fastbuild-android-ST-9b738726d3a8). Interestingly this does not appear to happen internally (i.e. with multiple values to --android_platforms)....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants