Reputation: 9615
I am trying to run react native app on my android device like this in cmd
cd C:\Users\User\Desktop\js
react-native run-android
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not find tools.jar
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.243 secs 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
Can anyone please tell me how to fix this problem?
Upvotes: 2
Views: 28729
Reputation: 175
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
Upvotes: 0
Reputation: 380
The solution if ur version of react-native >= 0.61.0. It shows error as when we add any plugin and use link command then it makes changes in android and ios folder. But when we remove plugin, it gets removed from package.json but inside android changes are not reverted and it gives error. So use below command to generate android folder again. I hope it will solve the error-
sudo rm -rf android/ ios/
yarn add react-native-eject
npx react-native eject
Upvotes: 0
Reputation: 807
Use the following step once, it may help you:
step 1: open cmd through administrator
step 2: navigate to your application by cd <path to your project>
step 3: run this command: ./gradlew clean
step 4: react-native run-android
Upvotes: 5
Reputation: 1261
I faced this issue while working on react-native project on Linux. In my case issue occured because I 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.
Upvotes: 0
Reputation: 65
Have you installed JDK and Android SDK properly? Are the JAVA_HOME
and ANDROID_HOME
properly placed in your environment variables?
Upvotes: 0