react-native run-android just rarely works - android

When I run react-native run-android I get the bellow Error:
BUILD FAILED
Total time: 19.668 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
But after running it for several times and having error, let say about five times, it works!
this process wastes so much of my time, so any suggestion is appreciated.

Install the app manually with adb in your emulator if not installed, then you could just use react-native start to start react native.

This problem occurred to me too.
If you don't have expo app installed on the emulator then download expo app and install it on your emulator, if you don't know how then see this post.
If you have it installed then clear the node cache as mentioned upwards and do npm start don't do npm start android, If don't work again then u reinstall all the packages but u must delete all the packages that are located on C:\Users\YOURUSERNAME\AppData\Roaming\npm and C:\Users\YOURUSERNAME\AppData\Roaming\npm-cache delete all those and then go here and create a new project from scratch, that worked for me.
And if you have expo software application on your computer don't use it ,it mess up your project with updates and so new problems come, just use the terminal.
Goodluck.

What helped me was to occasionally open and build the project using android studio. It will download all the gradle updates and android versions... most of the time I start the emulator from Android studio and the npm start to start the packager.

Related

Why does Android Studio - Flutter keep getting stuck after making any change in pubspec.yaml in ubuntu

I am having some trouble with Android Studio and flutter. Every time I make a change in the pubspec.yaml file of my flutter app and save the change, then run my app in my phone, my computer gets stuck while building the app.
Its stucks while running gradle -> Running Gradle task 'assembleDebug'...
I am forced to restart my laptop and then run AS again. The app will now run in my phone but anytime I open pubspec.yaml and make some dependency changes, then my computer will get stuck again and I have to restart again.
Below are some details that might be helpful.
I had tried the same with Ubuntu 18 and I was still getting a similar challenge.
How do I resolve this?
The solution was to change the Operating System and reinstall it again afresh. I did not manage to get a simpler solution

Getting an error running the simple initialised app in React Native

I've created the simple intitialised app via:
react-native init myApp
It creates it fine. And when I run it with:
react-native run-android
I get the following error:
Error: Unable to resolve module `./Libraries/YellowBox/YellowBox` from `node_modules\react-native\index.js`:
None of these files exist:
* node_modules\react-native\Libraries\YellowBox\YellowBox(.native|.android.js|.native.js|.js|.and....(continues)
The incredibly frustrating thing about this is that I've successfully run the initialised app (on previous initialisations) multiple times in the last few days. So I don't know why it won't run today (tried three initialisations today). I haven't changed the code one character from the intitialisation. I've tried restarting my computer, deleting my virtual android device (via Android Studio) and creating a new one. Still the same error keeps coming up. I've tried running it via my physical Android device, same error. I've tried deleting the node-modules from the project and reinstalling them (npm install). Same error. Any ideas?
I managed to solve it using this command:
react-native start --reset-cache
After start of the Metro run the app:
react-native run-android
In my case it happened after updating a package.
Ran into this same issue, found it to be a caching issue with metro.
YellowBox was moved to YellowBoxDeprecated.
I was able to fix this issue by doing the following:
delete node_modules and package-lock.json
clear metro-cache folder.(for windows default location is %appdata%\Local\Temp\metro-cache)
clear gradle cache (cd android & .\gradlew clean)
npm install the packages

Could not connect to development server - react native error

I had a react native project that is working fine and I switched to another project which is also a react native project. When I came back to the development of the first project I ran the following commands. I use a physical device to debug.
cd ./projectfolder
react-native start --reset-cache
react-native run-android in another terminal
Now the following problems are there, I would like to know what are the causes.
react-native start starts the Metro Bundler but it does not show the
loading progress of the files after react-native run-android
finishes. (Does not serve files)
Still the application starts without any red screen. (How does this
happen if the Metro Bundler has no progress shown?)
Since the application starts I can shake the running device and try
to enable the hot loading but it gives a error on the red screen.
(Sorry for the bad quality, I got this from internet. The same message is there on my physical device.)
I have tried the following methods.
Clear the npm cache using npm cache clean --force.
Make sure that the laptop and the mobile are on the same wifi.
Add android:usesCleartextTraffic="true" to the manifest since there are Android 9 related changes as per most github answers.
Uninstall the application and trying to run again.
Restarting everything.
Ran the bundle command and try but it will not help start the debugger.
Can I have any help on this? Thanks in advance.

Loading react native issue on emulator GenyMotion

I am using react native
react-native-cli: 2.0.1
react-native: 0.55.3
I was running via
react-native run-android
The screen is always loading the app (Debugger Mode)
NOTE: It was sudden issue, it was working fine till yesterday.
*PC is Restarted several time and also JS server using kill -9 PID
I've met this error before when I started to programming React Native on Ubuntu.
The reason why you got this error because your Genymotion didn't have same port with local machine.
So here is the solution:
Open the Developer Menu of mobile app on Genymotion
Choose the Debug Server port & port for device
Set the value localhost:8081
reload the app and enable the Debug. Now you can debug the app.
Cheer!
Maybe it is a problem with the app already installed in your phone.
Try running :
adb uninstall com.yourproject
This will install all of your project packages for all users on your emulator/phone
Temporary fix:
REACT_TERMINAL=<your terminal> react-native run-android
in my case with manjaro + xfce4:
REACT_TERMINAL=xfce4-terminal react-native run-android
or puts in your .bashrc:
export REACT_TERMINAL=xfce4-terminal

Cordova emulator not starting

I am trying to use the Android emulator to install an app on it.
Unfortunately the emulator is never starting up. I use the following
command in my cordova project:
cordova emulate android
The last output I get from console is:
Waiting for emulator...
But the emulator does never start (I waited 45 minutes now).
The path variables are all correctly set and I can start the
emulator using Eclipse or Android studio but not using the
command from cordova.
Any hints?
If you can start the emulator through android studio, then as a work around start the emulator outside and run the command
cordova run android
It will deploy your app in the already running emulator.
Check emulator path settings
https://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_index.md.html
If not able to execute then do :
use the alternate shell interface:
$ /path/to/project/cordova/run --emulator
Instead of relying on whichever emulator is currently enabled within the SDK, you can refer to each by the names you supply:
$ /path/to/project/cordova/run --target=NAME
Check the documentation above and see whether your PC supports virtualization or not.
I was getting the same issue, I resolved it by:
Open Android device manager, click on window -> Android Virtual Device Manager
There you will see listing of all the Android Virtual Devices, if you see any device with repairable icon on it, just click on repair and then try. It works.
I had the same problem. Though cordova started the emulator, the command line kept on saying 'Waiting for emulator...' forever.
The trick is, before running the command:
cordova run android
make sure you navigate into the android platform folder. That is, don't run the command from within the
/project folder
but instead from within
/project/platforms/android folder
That will launch your application in the Android emulator

Categories

Resources