[Solved] Error: Could not initialize class

I’ve setup the environment for react native on Windows. But when I run the command

react-native run-android

I get the following errors –

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Could not initialize class

How do I fix this?

Solution #1:

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"

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.

Solution #2:

This is a problem with JDK version 9. Android tools does not support building with Java 9 officially yet. And it has such problems.

Downgrading to Java version 8 will fix the problem.

Respondent: tasomaniac

Solution #3:

this because your classpath build tools in build.gradle root project is deprecated update like this for new android studio 3.1.2

buildscript {
    repositories {
    dependencies {
        classpath ''

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

Respondent: Hasan Jamshaid

Solution #4:

On Ubuntu 18.04, this fixed the problem.

  1. Run this command

    sudo apt-get install openjdk-8-jdk

  2. Add this to ~/.bashrc

    export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

  3. Restart your terminal or IDE.

Respondent: takasoft

Solution #5:

Fixed the error by adding the following in .bash_profile

 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=/Users/saif-ams/MyFiles/applications/androidsdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Respondent: Saif Kamaal

Solution #6:

The possible reason is the Gradle ‘s version and JDK’s version is not matched.

At begin, My computer’s gradle version is 4.10.1 and JDK is 12.

My solution is:

Download JDK 1.8 from oracle’s website, set JAVA_HOME with JDK8 and It done

Respondent: jerry

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy