So, you are in 2022, and changing the distribution URL does not work?
Yeah, React Native is such a pain. Make sure you have followed the React Native official guide, then check the Java version with:
java -version
Check compatibility matrix of Gradle versions. Change distribution URL to the version accordingly, from:
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-Y.Y-all.zip
where Y.Y
is the suitable version for your Java version.
And now, check that $JAVA_HOME
is set:
echo $JAVA_HOME
Damn, is empty!
Yes, this environment variable is required, and on Internet you will see examples of exporting this path, for example for MacOS:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
Be careful, this is not always the correct path. Check it navigating using cd
command. For me the path was:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"
Spot the difference. This could be anywhere, so check it carefully as this is the last step that will allow you to run your project with yarn example android
Tested on: macOS Bug Sur, version 11.4. Intel Core i5. Good luck with M1.
PS: I hate React Native required configurations.