8

I successfully setup react native to create new app in android on windows. But I stuck in this below mentioned error when I tried to run app in emulator. Can anyone help me to solved this issue? Thanks in Advance...

>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
R.evolvan
  • 91
  • 1
  • 1
  • 4
  • See http://stackoverflow.com/questions/11345193/gradle-does-not-find-tools-jar – Scott Tomaszewski Mar 23 '16 at 13:05
  • 2
    If anyone is getting this as the result of changing your project name, check `project/android/app/src/main/java/com` for a folder with the old name and remove it (as long as the correct renamed folder also exists). – rosendin Dec 30 '16 at 03:45

7 Answers7

6

I ran into the same problem. You need to set JAVA_HOME environment variable. To do that:

  1. Open your terminal by pressing Ctrl+Alt+T.
  2. Enter the following command: $ subl /etc/environment.
  3. Depending on where you installed your Java, you will need to provide the full path. For this example, I installed JDK 1.7 in the /usr/lib/jvm/jdk1.7.0_79 directory. Scroll to the end of the file and enter the following:

    JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79" export JAVA_HOME

  4. Save your file and exit sublime.
  5. Lastly, reload the system PATH with the following command: $ . /etc/environment.

This should fix your issue.

Manraj Singh
  • 123
  • 1
  • 10
2

If you are working with react native, just make sure you set up environment variables correctly for java compiler. after this goto package.json file in your project:

change this:

"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",

to: "react-native": "0.57.5",

save and run npm install

Source: https://github.com/facebook/react-native/issues/21722

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Archit Pandey
  • 167
  • 1
  • 7
0

Starting JS server... Starting the packager in a new window is not supported on Windows yet. Please start it manually using 'react-native start'.

Have you tried running this command in a separate cmd window?

To be clear, you should be in the root directory of your RN app when you run the command.

0

I faced that issue working on react-native project on Linux. In that case issue may also occur if you linked some external plugin and then removed it without unlink. In that case you can attentively read your console error message. It should point to place that source an error.

Aliaksei
  • 1,094
  • 11
  • 20
0

After searching and several attempts, I came to the following: In Android Studio, go to File > Project Structure > SDK Location > From the list of JDK location select the JDK version in my case jdk-15.0.1 JDK version

Jabbar
  • 1
  • 3
-4

Run:

react-native upgrade

and answer yes to all questions.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
-7
react-native upgrade

Works for me.

Pang
  • 9,564
  • 146
  • 81
  • 122
khenki
  • 1