-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Java 11 doesn't work with Android builds #8615
Comments
cc @jin |
cc @ahumesky |
this is a blocker for us because we're building in a Micronaut codebase on Java 12. is there any way the community can help? |
Any update on this issue? This has become a blocker for us to bump java version to 11 |
Looks like this gradle change needs to be replicated in bazel: https://cs.android.com/android-studio/platform/tools/base/+/79330f946ba270218ef06e34dfaed22c759c0613 Which is just unpacking an core-for-system-modules.jar with the sdk (30+) and passing the android jar in the classpath instead of bootclasspath. The core-for-system-modules.jar dependency makes it so that this only works for api 30 and above (not entirely sure why classpath is not enough though). |
We laid most of the groundwork for this with
I think most of what's needed here is to create a system directory containing the classes in |
To expand a little, this doesn't require changes to Bazel core, it 'just' requires creating a starlark rule that packages up e.g. something like
|
Using local JDK seems to work. But I need remote JDK to work, and to get any version between up to 13 working (a restriction per proguard 6.2.2), which leads me to this issue. Any practical info that could help me? I'm already building bazel from source in order to work around another issue (#13989), so I can edit anything needed to do so. I'm working off of release-6.0.0-pre.20220502.3rc1. Thanks in advance. |
I needed to build an android_library with a maven dependency on a classes on Java 17. My workaround was to use |
This works now with the recently released rules_android 0.6.0 release https://github.com/bazelbuild/rules_android/releases/tag/v0.6.0 |
Using Bazel at head (4aa48f9) and configuring the Java 11 language level with
--javacopt='--release 11'
(as currently suggested in #6245 (comment)) doesn't allow building Android targets.Repro:
Create a minimal
WORKSPACE
andBUILD
:Building with default options works:
Building with
--javacopt='--release 11'
doesn't:Setting
--javacopt='-verbose --release 11'
provides some hints about what's going on:The
search path for class files
shows that the expected bootclasspath jars are being passed to javac, includingandroid.jar
. But the[loading modules/java.base/java/lang/Object.class]
suggests that when targeting a language level that supports modules (i.e. Java >= 9), the compiler is ignoring the legacy bootclasspath configuration and looking at the host/exec JDK's module equivalent.That's supported by the javac docs:
The
--system
flag can be used to support this kind of cross compilation, but the argument is a path to a complete JDK containing the system APIs we're targeting, which we don't have forandroid.jar
.The text was updated successfully, but these errors were encountered: