Open Fingel opened 2 years ago
Thanks for the writeup!
For upgrading React Native to v0.65, I've just filed #5230. It sounds like either that, or a subsequent upgrade (v0.66 and v0.67 are now out too), will resolve this. So we can leave this here and let it be resolved by an upgrade.
Hi, so when I was trying to build the app on Android Emulator (Pixel 4 Google Play) via Android Studio on macOS Monterey (v 12.0.1), I ran into the same series of issues as mentioned by @Fingel above. And since the ideal solution is the upgrade of react-native version which is yet in progress, I tried to build the app with Java 15 instead of 17 considering the Gradle 6.9 configuration of the app. And ran into the following issue :
Looking up online, found this comment on an old Github thread discussing the above issue : https://github.com/alwx/react-native-photo-view/issues/189#issuecomment-911496526 which led to a suggestion to install Jetifier to provide support in : https://github.com/facebook/react-native/issues/25483#issuecomment-508446776 After installing Jetifier in the project as mentioned in the above comment, the app compiled successfully. So, I thought it might be useful to share this for new contributors trying to build the app locally on their machines until the upgraded version of Zulip app with latest react-native configuration gets released. Hope it helps.
@Mihir3 No changes like that should be necessary -- we already have a postinstall script that covers exactly that step.
In general, if you find you have to edit package.json
or any other file in order to build the app, that's always something we want to resolve in the main repository (either by changing some code, or clarifying something in our setup instructions) so that other contributors don't have to do that.
I'd be interested to hear more -- would you please file a new issue, with a copy-paste of the exact commands you tried and error output you saw? (It's clearly a different issue from the one this issue thread is for -- you were using Java 15, not Java 17 -- so a new issue is best.)
Or start a thread in #mobile
in the Zulip community server (https://zulip.com/development-community/) with the same information, and we'd be glad to help there.
@gnprice Thanks for the comment. And as suggested, I've opened a new issue #5288 describing the similar compilation issue.
When attempting to run the project under Java 17, the build fails with the following error:
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:
update-alternatives --java
. On Arch Linux you can usearchlinux-java
to set the default JRE after installing from the official repos.npx react-native start --reset-cache
. In theandroid
directory, I ran./gradlew clean
./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:
https://github.com/zulip/zulip-mobile/blob/29b08c50f792398de1272fdf9dc300befadd0354/android/gradle/wrapper/gradle-wrapper.properties#L9
Could the solution be upgrading Gradle?
Attempting to upgrade Gradle to the minimum version that supports Java 17 results in this error:
Which leads us to the following issue:
https://github.com/expo/expo/issues/12774
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:
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":
https://github.com/zulip/zulip-mobile/blob/29b08c50f792398de1272fdf9dc300befadd0354/yarn.lock#L9641
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 https://github.com/react-native-community/rn-diff-purge/issues/55 so that hopefully this can be resolved.