I’ve been creating an app with react native and keep running into this error. So far, all I’ve done has been to create a new project, make some basic pages for it with javascript in WebStorm and then now I’m trying to add support for firebase using react native firebase. With that, I haven’t even done anything yet I’m just trying to add the dependency and get it to run/build successfully. And I keep running into this error:
Task :react-native-firebase_app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':react-native-firebase_app:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':react-native-firebase_app:androidJdkImage'.
Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
Execution failed for JdkImageTransform: /Users/--/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
Error while executing process /Users/--/Library/Java/JavaVirtualMachines/openjdk-21.0.2/Contents/Home/bin/jlink with arguments {--module-path /Users/benfirstenberg/.gradle/caches/transforms-3/2971c19c96d163790ed915ee103f441f/transformed/output/temp/jmod --add-modules java.base --output /Users/benfirstenberg/.gradle/caches/transforms-3/2971c19c96d163790ed915ee103f441f/transformed/output/jdkImage --disable-plugin system-modules}
I’ve seen a few other people get this error and I’ve tried to replicate what they did, but it doesn’t seem to be working. I tried installing jetify. I tried uninstalling react-native-firebase and reinstalling it. I tried running ./gradlew clean. I tried correcting JAVA_HOME and ANDROID_HOME (although tbh I’m not certain I did those correctly). I installed JDK 21 and think I set it up correctly (again not certain).
I’d appreciate any help you can give. If the answer is that I need to update something or change a path like JAVA_HOME or ANDROID_HOME, I’d appreciate some help on knowing which to choose.
Thanks all
2
Answers
SOLVED. If anyone out there ever runs into this and can't get past it, you need to install JDK 17, not JDK 21.
I'll preface by saying I have no idea what I'm doing, but to do so, I downloaded the JDK from oracle (yes, they tell you not to but go ahead and do it), then added it to the directory /Library/Java/JavaVirtualMachines and then changed JAVA_HOME to reflect that new directory. It SEEMS to be okay to have more than one JDK (I have 17 and 21 in that directory) but I have a feeling it might come back to haunt me later.
try these .
2.clean rebuild the project – for that run the following commands in your project’s root directory it will clean and rebuild your project