Only JDK 8 will build with expo run:android - is that correct?

I’m using react-native-firebase and some of its plugins. I’ve run the expo prebuild --clean command and then expo run:android.

I’m currently forced to use JDK 8 or I receive a number of version-related errors for later JDKs.

All of the latest editors I’ve downloaded, from eclipse to VS Code, don’t seem to support JDK 8 anymore. You need to install older versions, by the looks of it: eg Eclipse Luna.

I’ve managed to get the command to work with Netbeans, which still allows JDK 8 to be used.

I feel as if I’ve done something wrong here, and that it may be related to gradle. I’m new to Java and React Native, so I’ve no idea what the issue is.

I can’t find anything in the documentation about the required JDK version.

Does anyone else need to use JDK 8?

When I initially ran expo run:android, it downloaded a gradle file automatically. I’m wondering if it downloaded it incorrectly and what needs to be done to fix the problem if that’s the case…

Hi @cmadden

With Expo (or React Native) you are generally writing JavaScript or TypeScript code and not Java/Kotlin/Objective C/Swift etc. so unless you can’t find a library that does something you absolutely need and you have to do it in native code, you are not going to need a Java IDE.

But if you do need to write some Java for your Android app you should probably be using Android Studio.

Thanks for the replay @wodin - but maybe I haven’t explained the issue correctly.

This stackoverflow thread somewhat explains the problem.

I had JDK 16 on the PC. I eventually managed to get JDK 8 working through a VS Code extension (so I could leave JDK at the latest on the PC). It’s compiling correctly now.

I think this does need to be explicitly called out somewhere in the docs though as it will not compile with the latest JDK. If there is a way of getting it to work without hacking gradle etc, I think that should also be documented. The compile errors are Java-related and can be obscure.

1 Like

react-native requires JDK 8, but this is a good point that we don’t call this out in our docs. it’s only mentioned on Running On Device · React Native

Does it require at least JDK 8 and can be run with newer versions? (from React Native: “If you have already installed JDK on your system, make sure it is JDK 8 or newer.” Setting up the development environment · React Native) I would like to compile to Java 11, but it seems to default to 8, even though my Java_Home and java version are set to 11. How can I make it compile for 11?

I read another post on stackoverflow where a dev commented he could never make it build on anything other than JDK 8. I’ve had the same problem - so globally I use the latest JDK, and then via VS Code I use JDK 8 and it works. Any version higher than JDK 8 generates errors for me.

Thanks! I’m trying to add native code (example code from google for displaying video ads) to the expo created Android project and it does not seem to like Java 8. I got the Google example working on a new Android project using Java 11 though :frowning: