我试图通过我的React项目运行反应本地运行Android。之后,我遇到了以下错误。
在CMD中显示错误
C:UsersekkawitDesktopReactNativemyapp>react-native run-android Scanning 557 folders for symlinks in C:UsersekkawitDesktopReactNativemyappnode_modules (15ms) Starting JS server... Building and installing the app on the device (cd android && gradlew.bat installDebug)... Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html
我成功安装了Android SDK,并成功地将Android Home和Path Environmental变量设置了。但是我仍然遇到相同的错误。
我还在PC上安装了用于创建虚拟Android设备的Gennymotion。
您通常会出现此错误,因为模拟器未运行或没有连接设备。因此,首先运行Android模拟器,然后在项目文件夹中使用react-native run-android
。
尝试在CMD/PS/Shell:
java -version
javac -version
如果Javac返回错误,则您不会安装JDK作为管理员。尝试卸载您的JDK,现在使用Admin