I want to build this project with Android Studio at launching, but take a error. Stacktrace is here

- 2,228
- 9
- 29
- 34

- 451
- 2
- 5
- 8
-
Please, fix your grammar, show your project setup, etc. – Eldelshell May 29 '16 at 18:54
-
@Eldelshell, wich specific configurations you want to see? – Usm May 29 '16 at 19:14
-
4Please don't link to external resources, include all relevant info directly in the question. – Henry Oct 30 '17 at 06:23
10 Answers
This problem occurs when there are multiple JDKs installed in your system, I had the same issue as I had mistakenly installed oracle-jdk-9 and Android studio requires oracle-jdk-8
If you are using Ubuntu you can install jdk-8 from this question.
So, Make following changes as shown below:
Press ctrl+shift+alt+s that will open project structure which can also be opened from
File -> Project Structure
And then change JDK Location where you may have installed JDK 8

- 692
- 1
- 8
- 21

- 516
- 5
- 3
this because your classpath build tools in build.gradle root project is deprecated update like this for new android studio 3.2.0
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
}
and after that update your minimum sdk and build tools to latest and no problem again

- 1,009
- 10
- 16
I had the same problem. I had installed Java 8 and Java 9.
I set JAVA_HOME
to Java 8, but Gradle was using Java 9.
I changed the JDK in File->Project Structure to Java 8 and it worked.

- 5,965
- 14
- 31
- 57

- 141
- 2
JAVA 9 has forcefully taken over the JAVA_HOME to itself.
after installing java9 you will find
# java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
So instead of uninstalling java 9 let us point the JAVA_HOME back to java 8
First find out the Android studio embeded JRE location
and add an entry in ~./bash_profile at last
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
# source ~/.bash_profile
# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
source http://scalebean.blogspot.com/2018/01/fix-gradle-could-not-initialize-class.html

- 9,630
- 6
- 59
- 60
Changing the JDK in Android Studio to point back at 8 didn't work for me. I uninstalled Java 9 and this solved the issue.

- 517
- 4
- 12
One simple solution:
React-Native isn't compatible with Java 9 or Java 10
Resolve this issue by simply downgrading to Java 8

- 1,695
- 19
- 17
-
Been trying every other solution in an attempt to build react on Java 10... your simple solution saved me further hours of work, thank you! – Mirage Sep 12 '18 at 13:01
-
1Ok, but how to do it? Incomplete answers doesn't help at all – brunoramonalmeida Oct 06 '18 at 13:58
Go to build.gradle,
and make sure your gradle dependencies up to date.
For Android studio 4.2.2
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
.........
.........
}

- 29
- 2
If you have several Javas in Ubuntu, you can
sudo update-alternatives --config java
sudo update-alternatives --config javac
to select the Java 8 that Android and Gradle need.

- 35,772
- 9
- 166
- 188
If anyone is having issues with IntelliJ IDEA, go to File
-> Project Structure
(or press Ctrl + Alt + Shift + S) and remove all JDK 9 entries. JDKs are marked under Platform Settings
-> SDKs
with a folder behind a tiny blue cup of coffee.
I tried adding the correct path to JDK 1.8 but IntelliJ IDEA will default back to JDK 9 for whatever reason. Unfortunately, I need JDK 9 for other projects, so uninstalling it would be too much of a hassle. If you need to use JDK 9 for another project (like I do), you can still add a JDK 9 entry via the same menu and then remove it again when required.

- 270
- 2
- 9
- 21
If the Problem Persists, just import the gradle to Android Studio and build the file inside the Android Studio.
Android Studio automatically handles gradle and sdk problems.
After successful build you can also try running the app via react-native run-android
in the
Command Prompt. Hope this Helps.
This was the only fix that fixed this issue.
I tried all the above answers but problem persisted

- 874
- 2
- 10
- 16