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

前端 未结 9 3298
太阳男子
太阳男子 2020-12-10 10:35

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

9条回答
  •  自闭症患者
    2020-12-10 11:05

    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

提交回复
热议问题