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

We Are Going To Discuss About Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler. So lets Start this Java Article.

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

  1. Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

    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

  2. Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

    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

Solution 1

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

Here is the link to image

Advertisements

Original Author Mihir Shah Of This Content

Solution 2

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

Advertisements

Original Author reza rahmad Of This Content

Solution 3

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.

Advertisements

Original Author Roberto Erhard Of This Content

Solution 4

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

Advertisements

Original Author HimalayanCoder Of This Content

Conclusion

Advertisements

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment