Skip to content

React Native is not compatible with JDK 18 #34103

@cortinico

Description

@cortinico

Description

I'm opening this issue for the sake of visibility/transparency.

We received multiple reports of users on JDK 18 not being able to build app for Android using the New Architecture

I did a small investigation on the JDK 18 support.

There are a couple of things to note here:

  1. Gradle don't formally support JDK 18 (https://docs.gradle.org/current/userguide/compatibility.html) as of today. The first version supporting it will be Gradle 7.5 (currently in RC).
  2. I've tried the RC, but it still crashes. I believe the problem might be somewhere in the JDK standard libraries or in how we use it. There seems to be a memory leak somewhere. It's curious that this happens only on JDK 18 (and not on 17).
  3. It would be interesting to try this on either a non-zulu or non-aarch64 jdk to understand if the problem is in the JDK distribution.
    That's the JDK I was using:
openjdk version "18.0.1" 2022-04-19
OpenJDK Runtime Environment Zulu18.30+11-CA (build 18.0.1+10)
OpenJDK 64-Bit Server VM Zulu18.30+11-CA (build 18.0.1+10, mixed mode, sharing)
  1. Having a heapdump of the crash would also be helpful. As the app instacrash, that's a bit tricky to do. I haven't managed to do this yet.

Version

0.68.0

Stacktrace

Error reporting crash
java.lang.OutOfMemoryError: Failed to allocate a 320848968 byte allocation with 4742061 free bytes and 187MB until OOM, target footprint 9582429, growth limit 201326592
	at java.util.Arrays.copyOf(Arrays.java:3257)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
	at java.lang.StringBuilder.append(StringBuilder.java:137)
	at java.lang.Throwable.toString(Throwable.java:493)
	at java.lang.String.valueOf(String.java:2924)
	at java.io.PrintWriter.println(PrintWriter.java:754)
	at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:778)
	at java.lang.Throwable.printStackTrace(Throwable.java:667)
	at java.lang.Throwable.printStackTrace(Throwable.java:735)
	at android.app.ApplicationErrorReport$CrashInfo.<init>(ApplicationErrorReport.java:354)
	at android.app.ApplicationErrorReport$ParcelableCrashInfo.<init>(ApplicationErrorReport.java:484)
	at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:157)
	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
	at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
	at java.lang.Thread.dispatchUncaughtException(Thread.java:2200)asdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions