错误:无法初始化com.android.sdklib.repository.AndroidSdkHandler类 [英] Error: Could not initialize class com.android.sdklib.repository.AndroidSdkHandler
问题描述
我已经设置了Windows上本机反应的环境.但是当我运行命令
I've setup the environment for react native on Windows. But when I run the command
react-native run-android
我收到以下错误-
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> Could not initialize class com.android.sdklib.repository.AndroidSdkHandler
我该如何解决?
推荐答案
在macOS中运行以下命令时遇到此错误
I encountered this error while running the following command in macOS
./gradlew assembleRelease --stacktrace
,并发布了确切的错误. 我通过为您的JDK安装设置$ JAVA_HOME环境变量解决了该问题.就我而言,我在适用于macOS的Android Studio中使用了捆绑的JDK:
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"
对于Windows,只需将JAVA_HOME添加到您指向的用户或系统变量中
for Windows, just add JAVA_HOME to your user or system variables pointing to
"C://Program Files/Java/jdk_1.x_"
文件夹,然后尝试再次运行react-native run-android.
folder and try running react-native run-android again.
这篇关于错误:无法初始化com.android.sdklib.repository.AndroidSdkHandler类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!