How to solve (Could not initialize class org.codehaus.groovy.reflection.ReflectionCache) issue in react native

I think I had the same issue. After installing RN (May 20th, 2020), I bumped into this error. I found this solution on https://github.com/gradle/gradle/issues/10248.

In short:

  1. Go to /android/gradle/wrapper/gradle-wrapper.properties file in your RN project

  2. Find this line that starts with distributionUrl. Change the gradle version into gradle-6.3-all.zip.

In my project, it was:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

and I changed it into:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

That's it.


I had the same error on Mac OS and React Native v0.62.

Apply these instructions correctly: React native environment setup

Adding this variable solved my problem:

export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"