TrinityTuts Tips

Set JAVA_HOME location for react native application

Fix Gradle Could not initialize class AndroidSdkHandler in Android react native application please follow below step to fix the error

Error:-

A problem occurred configuring project ‘:app’.

> Failed to notify project evaluation listener.

   > Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

Fix

Set Java home path to correct location in Mac Os

Step 1. Open a terminal and check Java Version

java -version

Step 2. Set Java Home path to correct location

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/

Hit enter and run command to run react native project again

react-native run-android

Done