I encountered this error while running the following command in macOS
./gradlew assembleRelease --stacktrace
and got the exact error posted.
I solved the problem by setting $JAVA_HOME environment variable to your JDK installation. In my case I used the bundled JDK in Android Studio for macOS:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
for Windows, just add JAVA_HOME to your user or system variables pointing to
"C://Program Files/Java/jdk_1.x_"
folder and try running react-native run-android again.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…