React Native - Error calling AppRegistry.runApplication - android

When I run a simple "AwesomeProject" app as stated in React Native Getting started page, the app runs on Nexus6 API 23 but error is shown. I also tried the following methods to solve the error:
adb reverse tcp:8081 tcp:8081, but doesn't work.
"react-native start" in command line before running the app but it does not show anything after "Loading Dependency Graph, done."
Running it on Nexus5X API 25 but still error occurs.
How do I solve it?

I found out that by typing:
react-native start --port 8081
in the command line, and running app by opening another cmd shell, I was able to run the app successfully. Thanks.

Related

Cannot get Android Emulator to Work on M1 Mac (RN Project)

It feels like I've tried every solution on the internet, and nothing seems to work. My emulators start, but they refuse to connect to my project no matter what I do. The build works and is currently in the Google Play Store, so it WORKS on Google, it's just my M1 is not letting me test on my machine in the most infuriating of ways.
my bash_profile looks like this...
export ANDROID_HOME="$PATH:/Users/**********/Library/Android/sdk
export PATH="$PATH:/Users/**********/Library/Android/sdk/platform-tools"
export PATH="$PATH:/ANDROID_HOME/emulator
export PATH="$PATH:/ANDROID_HOME/tools
export PATH="$PATH:/ANDROID_HOME/tools/bin
export PATH="$PATH:/ANDROID_HOME/platform-tools
and my project's local.properties looks like this...
sdk.dir=/Users/**********/Library/Android/sdk
and I have Android Studio installed and set up. Whenever I run npc react-native run-android I get this error...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
...
...
warn Failed to connect to development server using "adb reverse": spawnSync adb ENOENT
info Starting the app...
error Failed to start the app.
Error: spawnSync adb ENOENT
Fine, so if I try to start it via Android Studio, I get this following error...
Could not connect to development server.
Ensure that Metro is running
FINE, so let me spin up the hard downloaded Android Emulator and run it on that. I then get this error...
Unable to load script. Make sure you're either running Metro or that your bundle 'index.android.bundle` is packaged correctly for release
This is where I hit a wall, because I've never touched that file but I've gotten both this and other Android RN projects to run on my machine before. I sincerely have no idea what's going on, does anyone have a direction to point me?

Android Studio Refuses to Connect to React Native Server

Hi I'm trying to get the basic React Native tutorial here set up, under the CLI quickstart tab, but I keep running into issues. Please note that I'm trying to run this on an emulator.
Here are the specifics of my set up:
Mac OS: Mojave 10.14.5
Node: 14.15.5
npx: 6.14.11
gem: 3.2.3
watchman: 4.9.0
Android Studio: 3.5.3
JRE: 1.8
Running the command "react-native start" opens up Metro, shows this, but it never says "Done."
Running the command "npx react-native run android" causes this message on the terminal
BUILD SUCCESSFUL in 25s
27 actionable tasks: 5 executed, 22 up-to-date
info Connecting to the development server...
adb: error: cannot bind listener: Operation not permitted
warn Failed to connect to development server using "adb reverse": Command failed: /Users/Library/Android/sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.awesomeproject/.MainActivity }
On the emulator, this is what I see
I've hit the reload button, and gotten this screen on the emulator
then followed instructions detailed here and set up the IP address but still no luck. I've tried using the command "react-native run android" and it gives the same results as above.
This is the most basic project I can set up and I've followed the instructions listed on the tutorial to the letter multiple times with many fresh projects. I'm really not sure what more I can do or where I could've messed up. I've seen similar issues posted on other forums but they've all been closed without proper resolution. I've tried using "adb reverse tcp:8081 tcp:8081" as commonly suggested and it changed nothing.
iOS gives a separate issue entirely but I'll probably make that into a separate question. Does anyone how I can resolve this? What could the issue be here? It seems to be a common enough problem but there's no single agreed solution. Running the app directly in Android Studio results in the same issues too.
I've been trying to make this work for about two weeks now so I appreciate any help people can offer. Thanks.

Command 'react-native log-android' stuck at 'Starting Logkitty'

I'm trying to run a React Native project and after trying to start it, it produces an error which I'm trying to debug, but while trying to debug that error the command gets stuck.
I've tried using 'react-native log-android' but for some reason it gets stuck at 'Starting logkitty'
I had the same issue and the following solution worked for me.
First make sure you have an adb device connected to your system by running the command adb devices from you terminal and check if any devices get listed under the line: List of devices attached.
Now after running the command react-native log-android, 'Reload' code on your device and the logkitty should start logging fine.
The terminal may keep showing "info Starting logkitty" after npx react-native log-android command.
The log data may appear if present, after navigating through the screens of the project in an android device or emulator which is running the project after npx react-native run-android command.

React Native app: cannot connect to dev server, but the simulator is running - why?

The image describes my current situation properly. Please have a look at it first.
I am running my app on React Native. I have Android simulator on. I give the command to start the app. The app build finishes, but it says that virtual device not found, and in my simulator, if I open the app manually, it says that it cannot connect to Development server. It shows some issues.
Can anyone help?
Try run react-native run-android to connect your app to the emulator
Check USB Debugging is on(mostly running on virtual devices)
Check how you created project(react-native-cli or Expo) and run relevant app run command
Make sure your development server(node.js) is running when you run app. Sometimes it crashes then you have to again run command to run app
If all the step does not solve your issue try to uninstall app from device and run app again. Since react-native is still developing and its wired sometime these tricks works
I was having the same issue in Ubuntu 16.04. In my case the problem was that node packager wasn't running.
To check is packager is running easily you can open the browser and enter
http://localhost:8081/
You must see "React Native packager is running."
If you dont, then you can start packager from console running
react-native start
If you get an error like
" ERROR watch /your/project/path/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-ru ENOSPC"
Then run first
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Then run react-native start again and press the letter R twice in the emulator to reload.
Looking at the screenshot, seems like you don't have adb installed because there is a clear 'adb: not found error'.
Luckily Android studio ships with adb and is present in platform-tools under your Android SDK. (generally in /home/your-user-name/Android/Sdk/)
You only need to use it. Create a symbolic link in '/usr/bin/' or '/usr/local/bin/' depending how you'd like to use it.
Run the command:
sudo ln -s ~/Android/Sdk/platform-tools/adb /usr/local/bin/
After this run the app.

React Native App Returns "Application not registered" on Android

My React Native app (configured with the name "ctipsApp") works perfectly on iOS, but when running "react-native run-android", or starting it with Android Studio, the app returns the following error:
Application ctipsApp has not been registered. This is either due to a
require() error during initialization or failure to call
AppRegistry.registerComponent
I had setup the project via the command "react-native init ctipsApp" and the Android files show that this is the configured name. The index.android.js file also clearly contains the AppRegistry.registerComponent function and I am certain the file is being executed.
When I press the Reload button inside the app, it then returns the error that it couldn't connect to the development server.
The problem is that the app to computer interface is failing to load the needed files. This can be temporarily solved by running adb reverse tcp:8081 tcp:8081, which will fix the issue in connecting. (If the command adb can't be found run the full path such as /Users/noah/Library/Android/sdk//platform-tools/adb reverse tcp:8081 tcp:8081)
However, if you try to build the app and distribute it, then this solution won't fix the problem. To do that, you'll need to cache the bundle file that localhost:8081 provides.
Navigate to your project's root directory.
Run react-native start if the development server isn't already running.
Execute curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle".
You now have cached the bundle file in the Android assets folder. Whenever you update the code you will need to replace the cache with an updated version via the same steps as detailed above.

Categories

Resources