-
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
Building Android app (official tutorial) fails on Linux with JDK8 #6920
Comments
cc @cushon |
I have 1.8 as
This shouldn't happen because Bazel is using its embedded JDK to start itself, and should pick up your system JDK 8 automatically to build the Bazel app. |
I feel like I should include the full "can't create jvm"-error output, here it is, just reproduced on another computer with JDK8:
Due to having this error I started trying to pass toolchain-related flags to the build command. |
@dimsuz Is that problem Android related? Can you try to build regular java application in your environment? E.g.:
|
@davido Firstly, I had to add After this I tried your command and it gave me the following (another) error. Click to expand
|
I see a similar error with a Java binary built on a Mac using Bazel 0.22, and trying to run that binary with a Jdk 8.
Running like this:
It seems like the Java compiler used by Bazel 0.22 is miscompiling the code in some way. |
The code works with Jdk 11, but not with Jdk 8. |
This only seems to happen when I compile a jar and use that in another project. |
I have a repro:
I have both Jdk 8 and Jdk 11 installed on my Mac, and Jdk 11 is the default (what /usr/bin/java points to). |
@ulfjack I think that's WAI, then. The target It's equivalent to this:
or this:
This is a situation where you probably want to explicitly set
|
Oh, I see why this happens now. Someone overrode However, that means whoever checked in a jar in the deps of the dexer / sharder / whatever tool is used there used a newer Jdk. If the Android rules maintainers want to continue to allow running with Jdk 8, they'll need to replace the check-in jar with one compiled against Jdk 8. |
The .jar is bundled into Bazel as part of the release process, so apparently that's running with a newer version of the Jdk. Shouldn't we be running the embedded tools with the embedded Jdk then? |
@dimsuz says he's running with the |
Except he's using the arch linux package, which apparently doesn't include a Jdk? I think you'll need to file a bug against the arch linux bazel package about the NoSuchMethodError. |
Things to try:
One of these should work. If none of these work, but you need to keep using jdk8, then that'll require custom Bazel binaries / custom-built Android tools, I think. |
I saw the arch list, and it says "java-environment=10", but I don't know what that means. Technically, it's sufficient if you have a Jdk 10 installed - it doesn't have to be the default Jdk (that's possible at least on on Debian Linux and MacOS). |
Arch has the ability to have few of JDK implemenations installed (openjdk, sun + different versions), and it has a tool to select one of them as the default. I have to set the default to JDK 8, because Android Studio wouldn't let me build Gradle-based projects on JDK > 8 for some reason (I don't recall the exact error atm). That string is some kind of dynamic dependency specification I guess. I will try the things you listed above. I have JDK 10 installed:
|
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Initially I posted to #6164 because I saw a comment with an exact stack trace I get: #6164 (comment). Was advised by @jin to open a new issue instead.
Description of the problem / feature request:
I'm trying to follow an official Android Tutorial and cannot build the example app on a Linux sytem with JDK8.
To reproduce:
The command
bazel build //src/main:app
gives me a 'Can't start JVM' error, so I figured that's because I use java 8 (because Android):So I try to tell bazel about this:
And get an error in response:
Any hints on how to fix this? (Seeing how all relevant issues are closed I suspect I might be doing something wrong)
What operating system are you running Bazel on?
Arch Linux
What's the output of
bazel info release
?Reporting from home, can't include full output (from work), but it's version
0.20.0
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.I use Arch Linux bazel package
The text was updated successfully, but these errors were encountered: