I'm new to react-native, Android studio(for testing purposes).
What I'm trying to do?
well, I have build an a react native app using create-react-native and then I got the app, I've installed Android-studio then, No Issue.
what went wrong?
When I run the app using yarn android which is pretty much recommended by them, I got this error
info Launching emulator...
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
What I've tried so far ...?
I have tried to launch it manually but it doesn't connect to the app.
Launch it manually means:
1- yarn start
2- launching the simulator from inside the Android studio
Related
Why Expo go app not working. But in my browser it works.
Again I create with "npm init" and again did same process .This time no errors .I used Expo App from started instead of Web as a emulator. The reason for this problem is in web Emulator not showing some errors
related to the real emulators.
Every time if I want to run RN project I want to start an android studio and start the emulator manually and then go to the terminal and run the RN. if i run the project without starting an emulator it's giving me an error.
error I got when I run the project without starting an emulaotr
from my experience this is expected behavior. On Mac, running an iOS project is able to open the built in emulator, but never on Android. The error is just letting you know there are no devices running.
One helpful thing you can do is create a shortcut or terminal command to open your emulator without opening Android Studio, which is kind of a pain to open just to start an emulator. You can do this using something like what is mentioned here: https://stackoverflow.com/a/33487044/3218158
Supposedly the two ways you can start a react native android app are:
react-native run-android via command line
OR
Open your project in android studio and press Run.
The issues I am experiencing are that using option 1, i will get an error that no devices are available:
com.android.builder.testing.api.DeviceException: No connected devices!
and using option 2 results in an emulator starting and the installation of the app successfully, but the JS packager doesnt start as part of this flow.
Now sure, I can easily get around this by either
Run the packager manually before starting the app in Studio
Starting an emulator before running react-native run-android
but it seems like this is indicative of a problem somewhere
I have checked out this similar question here React Native: Android Studio doesn't automatically bundle when building but that is unrelated to whats happening to me
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.
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