Task :app:compileDebugJavaWithJavac FAILED - react-native

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.

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

TypeError: global.__reanimatedWorkletInit is not a function. (In 'global.__reanimatedWorkletInit(_f)', 'global.__reanimatedWorkletInit' is undefined)

TypeError: global.__reanimatedWorkletInit is not a function. (In 'global.__reanimatedWorkletInit(_f)', 'global.__reanimatedWorkletInit' is undefined)
I am using React Native (not expo). I don't even have reanimated downloaded. I had it downloaded then I removed it and rebuilt the app, and it's giving me this error now.
Things I've tried:
deleting node_modules and re-running yarn install
-git reset HEAD~ to a prev commit where I didn't install the reanimated2 packages
I just followed the below steps to solve this issue.
step1: npx react-native run-android
step2: npm start -- --reset-cache
and it solved
Ok, what I ended up doing to solve this was:
-just deleted the whole repo from my local
-cloned it again from github
-uninstalled the app from Android emulator
Then it seemed to work. So maybe it was an error related to cache or something lingering around even after I had removed all instances of the word/package "reanimated" from the whole codebase.
Using Expo in a bareworkflow
Clear app memory
run expo start --dev-client --clear
I solved my issue doing this:
https://github.com/wcandillon/react-native-redash/issues/395
On top you just have to do this: import 'react-native-reanimated';
on your app or index file.
I have tried all the solutions from stack Overflow. (Not working)
Here is the fix:
first check your version for react-native-reanimated and then see the actual documentation of the right version for the configuration.
I am using version 2.4.1 and have solved by this link
I had a require cycle warning from a git submodule inside the src folder which I thought wasn't doing any harm but turns out fixing that solved this issue. I am unsure why the require cycle was causing so much grief but I guess if you've got a require cycle in your output try solving that and it may fix this.
What I did was degrading react-native-reanimated to ^2.6.0. It solved the issue for me.
I had this problem too and simply moved the babel plugin react-native-reanimated/plugin to the last place in the babel's config as stated in the doc.
I should probably mention it worked for me before but when I started migrating the react-native app for web this was the problem for me. I am using expo. I had to run expo with --clear CLI arg as expo start --dev-client --clear.
I Just solved this issue by doing these steps:
close Metro bundler
run this command
npm start -- --reset-cache
react-native start --reset-cache
rebuild the project again

react-native android app quits before it launches (0.61.2) - couldn't find DSO to load: libhermes.so - Channel is unrecoverably broken

I have been trying to migrate from react-native 0.59.4 to 0.61.2.
After solving many many build and runtime problems on ios and android, this was the final problem before the successful launch of my react-native app on android. The app would build successfully but when it is time to launch on the emulator it would pop for a very brief moment then a white screen and application crashed with an app keeps crashing type of popup message. I can't even debug the app remotely on the chrome console since it doesn't launch in the first place.
Any ideas?
Note: This solution worked for my specific problem. To find out your problem try adb logcat *:E to see what is wrong in your case.
Ok, there is a very important command (I am on mac) that helps you see in the logs what is going on even if you can't launch the app on emulator: adb logcat *:E
In my case there were 2 main problems that caught my attention in the logs.
Channel is unrecoverably broken and will be disposed
and
couldn't find DSO to load: libhermes.so
Once I got these messages on my radar I started to dig/google for them.
After going through a lot of SO and GitHub topics here is what worked for me:
First, make sure you have made all the necessary modifications in your:
gradle.properties
app/build.gradle
android/build.gradle
package.json
etc
files (Use react-native upgrade helper to do this).
Then, if it is not installed already, do npm install jsc-android to install the required jsc package on your project.
Add the below in android/build.graddle inside allprojects -> repositories
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
Inside gradle.properties add
android.useAndroidX=true
android.enableJetifier=true
In some cases you may need to add below line to package.json
"postinstall": "npx jetify"
Also, in some cases it may help to replace the below line (dependencies section of app/build.gradle) with the exact version of the react-native you are using:
implementation "com.facebook.react:react-native:+"
Replace like so:
implementation "com.facebook.react:react-native:**0.61.2**"
I hope this helps to solve or at least make some progress with your problem.
Cheers.

Package not linking - error: package com.beefe.picker does not exist import com.beefe.picker.PickerViewPackage;

I have tried running npm install react-native-picker --save
react-native-link
etc but the package remains missing every time I run react-native run-android
https://github.com/beefe/react-native-picker/issues/67
Nothing I tried from this list works. I would like suggestions on debugging this type of react-native error. The node_module is there. What else could be keeping it from being visible during react-native run-android? Is this a failure to link? Is it a failure to compile? How do I debug this?
Ok, solution is work around wrong version of Android compile and target at 27. Work around is to go into node_modules of picker and modify android.gradle under app to switch 27 to 28 for target etc. That fixes it.

Best way to upgrade react-native project

I have a question about upgrading react-native version.
We have some choices to upgrade but I don't know differences.
1) react-native upgrade
2) react-native-git-upgrade
3) npm install react-native#latest --save then react-native run-android or react-native run-ios
I used third way for my project because I need to maintain my files in the android folder like MainActivity.java, MainApplication.java, AndroidManifest etc.
could you please describe differences between these ways?
TL;DR
First, you should check out the latest options for upgrading from facebook.
If none of those work for you:
Increase version of react-native in your package.json
run npm install (or yarn if you're using that)
run react-native upgrade or possibly react-native upgrade --legacy
Explanation
Here I address each of the upgrade options you asked about.
1) npm install react-native#latest --save then react-native
run-android or react-native run-ios
As you probably know, the run-* commands here don't perform any type of upgrade.
Meanwhile, npm install --save <library>#<version> is just the command to put a library into your package.json, or update the version of an existing library. This is how you would upgrade the version of any typical library in your package.json. If that's all there was to upgrading RN, there would be no fuss amongst the community about the difficulty of upgrading. There's much more work to do.
If this is the only step you take in upgrading, the new version of react-native will be downloaded to node_modules, but it should fail and complain about many things:
react dependency needs to be upgraded as well
Files under your ios and android directories will not be in the state which the latest react-native expects. For example, if you upgrade from react-native 0.52 to 0.59, you will have gradle 2 while your react-native library expects gradle 4.
Your other dependencies might not work with your newer version of RN. For example, here is a warning from npm install after I did my upgrade:
npm WARN react-native-markdown-renderer#3.2.8 requires a peer of react-native#^0.50.4 but none is installed. You must install peer dependencies yourself.
As you can see, I need to upgrade native-markdown-renderer as well, since it requires RN 0.50 but I've upgraded to 0.59. Some libraries might work in this mismatched state, but that is your risk to take.
2) react-native-git-upgrade
From what I understand, the RN team had too many problems with this product and no longer want us using it. I'm guessing this is why it doesn't work at all for most of us.
3) react-native upgrade
This will update the version of react-native in your package.json, but then also bring you through a set of guided CLI prompt as it modifies the files in your ios and android directories. But how will this guide handle conflicts between the new incoming files and your existing files? You likely have some changes in there you want to keep.
Newer versions of react-native upgrade are said to allow you to perform a diff and merge, but I haven't seen that. When I ran it, it intended to clobber my entire old file with a new one, and it showed me the path on my local file system to the "new" version that would overwrite my old one. So I used my own diffing tool to just diff between the new incoming file and my existing file. If you lack a diff tool, I use p4Merge. So, as you go through the CLI guide, just do a diff between your existing file and the path to the new file it gives you, and do that one by one, adding necessary new lines to your files. If you made some changes, answer "no" to the prompt so that you can keep your old file (with the modifications you just made). If you don't have anything worth keeping in the file, answer "yes" and let the guide simply overwrite and clobber your old file.
When this command is complete, your ios and android directories will be updated. For example, gradle will be upraded from Gradle 2 to Gradle 4.
You may hit the bug I did, which causes this command to keep upgrading you to an OLDER version rather than the latest. In this case, you need to instead run: react-native upgrade --legacy
If it's a smaller project just create a new react native project using 'npx react-native init yourprojectname --version X.XX.Xt' and then copy the source folder of your older project into the new project. Then try running it in android or ios using 'npx react-native run-android' or 'npx react-native run-ios'. If there are any runtime errors but no build errors, then update the npm packages accordingly. Note: This is applicable for small projects because larger projects may contain many 3rd party dependencies. :)
I tried react-native-git-upgrade and then deleted node_modules and then npm install
it works for me!
https://facebook.github.io/react-native/docs/upgrading
The upgrade approaches mentioned in the other answers do work in many cases, but I have experienced many other cases where there are too many errors.
From my experience, in these cases the best approach is to create a new project in the new version, and copy the source files to the new project.

React native RTCRootView.h not found

I'm trying to use React native and I am getting an error in xcode that says "Lexical or preprocessor error 'RTCRootView.h' not found." I have checked and this file is in the framework folder and I have tried moving it into the project as well and still have not been able to eliminate the error and successfully build.
In the example directory, run npm install to install the dependencies.
Then, open swipeoutExample.xcodeproj and run.
react-native-swipeout#15.
edit (2015-10-12):
react-native-swipeout has been updated to use the latest react-native including ./ios and ./android directories.
iOS: Open the xcode project in the ./ios directory and run it.
Android: Start a simulator, then run react-native run-android in project root directory. (note: swipeout is currently incompatible with Android, but will be soon.)
Running npm install might work for some people, but it didn't work for me.
What worked for me was in XCode > Product > Clean
Sometimes it might be because the node_modules folder is missing in your project directory.
Move the node_modules folder to your project
run npm install in your project directory
Just faced with the same error. In my case it was because of typing error. I replaced RTCRootView.h with RCTRootView.h (RCT is an abbreviation of ReaCT).