react-native run-android not detecting emulator or device - android

When I run react-native run-android to run my React Native app I get this error and then the build fails:
'C:\Users\Alex\AppData\Local\Android\Sdk/platform-tools/adb' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
I get this error whether I run the command with my phone connect by USB or if I run it with the emulator open from Android Studio. However, when I run adb devices both the emulator and my device show up.
I am pretty sure it is not a problem with the React Native code because I have tried running multiple different apps and get the same error.
Does anyone know what could be the problem and why the device and emulator aren't detected?

The problem was that my computer's antivirus had deleted adb.exe so once I reinstalled the platform tools folder containing adb.exe, react-native run-android worked as normal and my connected device was detected.

Related

How to run react-native expo app on multiple emulators?

Does anyone know how to run an expo react-native app on multiple android emulators at once?
I have tried to run the app after running the emulators but it would run only on one emulator.
When I tried 'shift+a' it shows a list of emulators but when I choose the desired emulator it doesn't work.
This is the error 'Couldn't start a project on Android: The emulator (Nexus_S_API_30) quit before it finished opening. You can try starting the emulator manually from the terminal with: emulator #Nexus_S_API_30'
This says the emulator exited even though it is already running.
Install app in all emulator
Open all emulator
Run project from different port
For example
Run 'npx react-native start' for first emulator
Run 'npx react-native start --port 9988' from another terminal for second emulator etc
Open app from emulators
Open developer menu by pressing ctrl + m
Change bundle location to '10.0.2.2:PortNumber' eg : '10.0.2.2:9988'

Android Studio Application Installation failed

Sometimes when I go to build and test my apps I get this error and it drives me off the wall. I never had to deal with this before.
Installation Failure
com.android.ddmlib.InstallException: 'cmd package install-create -r -t --full -S 2816556' returns error 'Unknown failure: cmd: Can't find service: package'
I tried following this guide here
Application Installation Failed in Android Studio
I did all the suggestions disable instant run, build apk then rebuild app, restart computer, restart android studio, use different virtual device.
Idk anymore any ideas? I am using Android Studio 3.4.1
Update: Fixed it my issue sorta. If i first launch my virtual device and get it loaded. Then run my app the error doesn't pop up. This leads me to believe that Android Studio will throw the installation error because it can't run the app on the virtual device since it takes forever to load on my laptop

react-native run-android: usb debugging not working

I have installed the development environment for react native on Windows 7 using the instructions here.
I have installed the following packages:
Python 2.7
node 4.2.4
npm 2.14.12
react-native-cli 0.1.10
react-native 0.18.0-rc
Android SDK
I can generate a skeleton project using the command react-native init Test.
However, when I execute the command react-native run-android, the following error occurs: Unable to install path\to\app-debug.apk.
The device, a Samsung Galuxy running Android 5.0.1, is connected to my PC and USB debugging on the phone has been enabled. When I type adb devices the phone appears in the list.
I can download the apk to the phone manually using the command adb install. However, when I run the app, a red screen appears with the error "Unable to download js bundle." This error persists even after I do the following:
Start the local development server using react-native start
Executing the command: adb reverse tcp:8081 tcp:8081
On the phone, setting the debug server host and port to localhost:8081
Update: I have solved one problem by downloading gradle to version 1.2.3 as described here. However, the red screen still appears with the error Unable to download js bundle.
What could be the problem?
You are working fine. for this problem have added the IP address in device Setting server host. one more thing your machine and device should have on same network.

How to set the default Android Emulator

I am building an app with NativeScript, where I run:
$ tns run android --emulator
to build the app and launch it in an emulator. When I do this, the default android emulator boots on my machine, which is unusably slow...
In all the demos, they are using the Genymotion Emulator. I have installed this, but the NativeScript command still launches the default emulator. How do I get this to launch on the genymotion emulator?
NB: I am using Windows 10
Update:
Even if I run the command with the Genymotion emulator running (and nothing else), I get the following log output and a new terminal window is opened running android-sdk/tools/emulator-arm.exe
BUILD SUCCESSFUL
Total time: 11.959 secs
Project successfully built.
Using C:\Users\George\Source\Repos\NativeScript-App\Bluetooth\platforms\android\build\outputs\apk\bluetoothdemo-debug.apk
Starting Android emulator with image Xamarin_Android_API_23
That looks as though it is referencing the emulator I had been using when I was developing with Xamarin. Any ideas where I can change that, or why that is being called?
start Genymotion, then start one of the devices that you have setup in Genymotion
then check that the device is seen:
$ tns device
then run nativescript like so
$tns run android --geny 192.111.222.33:555
(or whatever is the name that you get from the tns device command)
To my experience --emulator always tries to start the stock emulators. Try to start genymotion and then just tns run android (w/o the --emulator option).
I think it does that when there is no emulator running.
Try starting Genymotion first, launch the image you want, then run the "tns run adroid" command.
I had a similar issue.
To use GenyMotion by default, first delete all the Android emulators using
android avd
I then followed the solution on this thread:
React-Native, Android, Genymotion: ADB server didn't ACK
Edit the settings in GenyMotion to use the android SDK you downloaded. (path for Windows is Users/YOUR-SYSTEM/AppData/Local/Android/android-sdk)
You still have to run the device on GenyMotion before running the emulator
tns run android

Error when launching .apk on android studio emulator

I am building an app with ai2 but I have spend hours trying to get their emulator to work, so I have exported myapp.apk and I am trying to launch it on android studio emulator.
I have followed several tuto included the answer proposed by Tarek on that thread But I am getting and error on cmd.
Here is what I tried:
run android studio as administrator, run the emulator via the AVD manager, waited until it's started.
move myapp.apk in the sdk/platform-tools folder
created a run.bat file in this folder and wrote CMD in it5. copy your desired apk to the same folder
double click on run.bat and wrote: adb install r- "myapp.apk"
Here I am getting an error on CMD: error device not found -waiting for device-. I don't understand because my emulator is running.
I have also tried to launch the emulator without starting android studio with this command emulator -avd <avd_name> [<options>] but I get this message "the system cannot find the file specified".
The error message appears because adb cannot connect to the device although it is running. This is not supposed to happen, but it does from time to time.
You can always check if adb can see the emulator by running adb devices, which should result in a list of devices it can see. If this list is empty, the device is not found. You can resolve this by adb kill-server, waiting a couple of seconds and then running adb start-server. Try running adb devices again, and the device should be listed, and the installation should succeed.
Starting an emulator can be done by running emulator #<device-name> [options]. The device name can be found by running android list avd. This will result in a list of devices of which the <device-name> will also be listed.

Categories

Resources