Error: Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

Solution 1:

This is because your classpath build tools in build.gradle root project is deprecated. Update it like this

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
    }
}

and after that update your minimum sdk and build tools to latest and no problem again

Solution 2:

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.