我成功设置反应原生在Windows上的android中创建新的应用程序。但是当我尝试在模拟器中运行应用程序时,我陷入了下面提到的错误。任何人都可以帮我解决这个问题吗? 在此先感谢...
>react-native run-android
'which' is not recognized as an internal or external command,
operable program or batch file.
Starting JS server...
Starting the packager in a new window is not supported on Windows yet.
Please start it manually using 'react-native start'.
We believe the best Windows support will come from a community of people
using React Native on Windows on a daily basis.
Would you be up for sending a pull request?
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee081Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore081Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline081Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp081Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0222Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
**:app:compileDebugJavaWithJavac FAILED**
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar
答案 0 :(得分:5)
我遇到了同样的问题。您需要设置JAVA_HOME
环境变量。要做到这一点:
$ subl /etc/environment
。 根据您安装Java的位置,您需要提供完整路径。对于此示例,我在JDK 1.7
目录中安装了/usr/lib/jvm/jdk1.7.0_79
。滚动到文件末尾并输入以下内容:
JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79"
export JAVA_HOME
$ . /etc/environment
。这可以解决您的问题。
答案 1 :(得分:2)
如果使用React native,只需确保为Java编译器正确设置了环境变量。 在您项目中的goto package.json文件之后:
更改此内容:
“ react-native”:“ https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz”,
至: “ react-native”:“ 0.57.5”,
保存并运行npm install
这对我有用。
来源:https://github.com/facebook/react-native/issues/21722
谢谢,祝您编程愉快!
答案 2 :(得分:0)
启动JS服务器... Windows上不支持在新窗口中启动打包程序。 请使用' react-native start'手动启动。
您是否尝试在单独的cmd窗口中运行此命令?
要清楚,运行命令时应该位于RN应用程序的根目录中。
答案 3 :(得分:0)
我在Linux上的本机项目中遇到了这个问题。 在这种情况下,如果您链接了一些外部插件,然后在没有取消链接的情况下将其删除,也可能会出现问题。在这种情况下,您可以专心阅读控制台错误消息。应该指出该错误源。
答案 4 :(得分:-2)
运行react-native upgrade并对所有问题回答“是”
它适用于你
答案 5 :(得分:-4)
react-native upgrade
适合我。