Task :app:compileDebugJavaWithJavac FAILED

Viewed 154

I've tried looking for a way to solve this error. It's occurring to me while I try to install my app with react-native run-android.

Already took a look at the solutions from this thread, but my project isn't named native, ./gradlew clean from the android folder didn't work, and I tried deleting the .gradle folder. I've also tried my own simple solutions that sometimes work for whatever reason - uninstalling the app from my phone before re-running react-native run-android and reopening VSCode.

This error started occurring after I installed react-native-unimodules, following the android instructions. A potential problem I see from this is just that react-native-unimodules is supposed to be for Expo and I'm doing things with React Native CLI, but from what I understood, this is allowed.

My react-native version is 0.61.5, react-native-cli is 2.0.1.

Edit: build.gradle file, as requested. Also, I don't know if it's relevant, but since it was part of one of the suggested answers, I'll mention this as well: in the gradle.properties file, android.useAndroidX=true and android.enableJetifier=true were already present.

1 Answers

This is a pretty common case, but what ive figured out during my app building, these steps always helped.

First you need to add below lines in gradle.properties file

android.useAndroidX=true
android.enableJetifier=true

Then after that you need to install, jetfier via either yarn or npm like :

npm i jetifier // first this then the below

npx jetify

After that again re-bundle your code and then run, hope it helps. Feel free for doubts

Related