app:compileDebugJavaWithJavac FAILED

Viewed 27330

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
7 Answers

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

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.

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

Run:

react-native upgrade

and answer yes to all questions.

Related