-
-
Notifications
You must be signed in to change notification settings - Fork 677
Description
When attempting to run the project under Java 17, the build fails with the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @32d74d85
Running the build on Java 11 does not result in this error.
System Information:
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12)
OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)
Linux 5.16.8-arch1-1
Steps to reproduce:
- You'll need to have Java 17 installed, but you probably don't want to get rid of your (working) version already installed. If you are on Linux, most distros provide some way of switching the current default JRE. In debian/ubuntu based distros, you can install Java 17 using apt and use
update-alternatives --java. On Arch Linux you can usearchlinux-javato set the default JRE after installing from the official repos. - Clean and rebuild the project. In the root of the project, I ran
npx react-native start --reset-cache. In theandroiddirectory, I ran./gradlew clean - Start the project with
./tools/run-android --stacktrace --info
Googling the specific error returns this SO question as the first result:
https://stackoverflow.com/questions/67782975/how-to-fix-the-module-java-base-does-not-opens-java-io-to-unnamed-module
While it's not clear to me the exact reason for the specific error, the general consensus appears to be a mismatch between Gradle and JRE versions.
Gradle provides a compatibility matrix here: https://docs.gradle.org/current/userguide/compatibility.html
And indeed the first version of Gradle to support Java 17 is 7.3. It appears zulip-mobile is using 6.9:
| distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip |
Could the solution be upgrading Gradle?
Attempting to upgrade Gradle to the minimum version that supports Java 17 results in this error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/austin/Documents/zulip/code/zulip-mobile/node_modules/expo/android/build.gradle' line: 3
* What went wrong:
A problem occurred evaluating project ':expo'.
> Plugin with id 'maven' not found.
Which leads us to the following issue:
So it appears that only the latest versions of react-native and expo support Java17/Grade 7. So the right call might be to upgrade react-native itself.
The documentation mentions using the upgrade tool: https://reactnative.dev/docs/upgrading#1-run-the-upgrade-command which in turn uses this project: https://github.com/react-native-community/rn-diff-purge#diff-table-full-table-here to provide diffs for each react-native version upgrade. However, attempting to run the upgrade tool gives us a 404:
info No version passed. Fetching latest...
(node:292856) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
info Fetching diff between v0.64.3 and v0.67.2...
error Fetch request failed with status 404: 404: Not Found.
error Failed to fetch diff for react-native@0.67.2. Maybe it's not released yet?
info For available releases to diff see: https://github.com/react-native-community/rn-diff-purge#diff-table-full-table-here
This is interesting because that project is supposed to provide a diff matrix for each react-native version to every version after it. We are currently on version "0.64.3":
Line 9641 in 29b08c5
| version "0.64.3" |
However, that version appears to be missing from the upgrade matrix: https://react-native-community.github.io/rn-diff-purge/
causing the upgrade tool to fail.
I have opened an issue with rn-diff-purge react-native-community/rn-diff-purge#55 so that hopefully this can be resolved.