I was able to build app using expo build:android previously. However, after upgrading to latest expo version I get following error:
connect ECONNREFUSED 127.0.0.1:19001
Set EXPO_DEBUG=true in your env to view the stack trace.
I also see the following lines in the log:
Publishing to channel 'default'...
Building iOS bundle
I don't added ios to my app.json, I only need to build an android apk. To do that I use expo build:android -t app-bundle
I also removed package-lock.json and node_modules and run npm install, but I get the same error.
I run expo start on another cmd and then run expo build:android -t app-bundle still get same error
Also when I clear expo cache, see the following log:
Restarting Metro Bundler...
Starting Metro Bundler on port 19001.
Couldn't adb reverse: adb.exe: error: Invalid source port: 'undefined'
I had faced same issue myself and found the solution. Expo is looking for localhost:19001 which is not running. Just follow following steps and it should work as expected:
Run expo start no terminal and once it opens up the
browser where you will find this line written Starting Metro
Bundler on port 19001.
Now open another terminal instance and run expo build:android.
I'm starting an app from Re-Natal template (didn't change it; project.clj from https://github.com/drapanjanas/re-natal/blob/master/resources/project.clj).
Then I ran
react-native start
re-natal use-android-device avd
re-natal use-figwheel
lein figwheel android
react-native run-android
The app runs ok on the device, but the repl stays at Prompt will show when Figwheel connects to your application, and the code won't reload.
The same happens on a real android device.
I'm also reloading the app after it starts.
Am I missing something?
Update: output from react-native run-android
Installing APK 'app-debug.apk' on 'Nexus_5X_API_28(AVD) - 9' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL
Total time: 36.329 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Running /home/ale/Android/Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Starting the app on emulator-5554 (/home/ale/Android/Sdk/platform-tools/adb -s emulator-5554 shell am start -n com.renatal/com.renatal.MainActivity)...
Starting: Intent { cmp=com.renatal/.MainActivity }
I have had this in other cases as well but one case in which this will happen is when you have done a production build with Leiningen and not subsequently re-run re-natal use-figwheel. To solve this you would have to
Run re-natal use-figwheel
Relaunch react-native start / npm run start
Reload the Android app.
I try build react-native run-android on windows this bug appear
then i do follow the answer on this github issue try Command chmod 755 android/gradlew on root folder but chmod' is not recognized as an internal or external command,
operable program or batch file. i think this answer for linux . Some body help me . Thanks for reading my question
The error states that you neither have any android device connected nor do you have emulator running. Follow this guide for android setup.
If you already have android setup and running emulator, try restarting it and run following commands:
Try running following commands:
cd android && ./gradlew clean
cd .. && react-native run-android
From your question seems like you are not started your emulator or device connected.
Follow this steps:-
1.Open your CMD/Terminal from your system
write this command cd "YOUR PATH TO ANDROID SDK"
for example, mine looks like::-
cd /Users/trainee02/Library/Android/sdk/platform-tools
and then hit enter.
3.after enter in directory write this command
export PATH="/Users/YOUR SYSTEM USER NAME/Library/Android/sdk/platform-tools":$PATH
above command is for running android from MAC pc.
then last command is
4.adb reverse tcp:8081 tcp:8081
hit enter
or you can check reference that given in official site
Running On Device React Native
You must update Tools sdk revision 23.0.1 on Android Studio
I am building an app using react-native and i was using android default emulator without any problems. The only issue i am having is the emulator is really slow.
I wanted to try genymotion and installed it. How ever when i run react-native run-android it cannot find the Genymotion Emulator. Here is the Error i am seeing in the console.
BUILD SUCCESSFUL
Total time: 8.329 secs
This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
ADB server didn't ACK
* failed to start daemon *
error:
Starting the app (/home/hduser/Android/Sdk//platform-tools/adb shell am start -n com.legacitinative/.MainActivity...
error: no devices/emulators found
I am not sure why it cannot find the emulator.
Appreciate any help.
Thanks
Sateesh
$ cd /home/hduser/Android/Sdk/platform-tools
$ ./adb reverse tcp:8081 tcp:8081
Try if adb can see your device with
$ ./adb devices
Is it possible to use the run-android command for one specific device only?
For example, if I have three devices (or emulators) connected and I want to use run-android on only one of them?
Maybe something like adb install -s DEVICE_NUMBER?
To run react-native application on optional device you can specify some flags in run command. To see available add --help:
react-native run-android --help
Then you can specify your device id throught --deviceId
react-native run-android --deviceId=DEVICE_ID
To see available devices ids'
adb devices
To list AVDs:
$ANDROID_HOME/tools/emulator -list-avds
To run a specific emulator:
$ANDROID_HOME/tools/emulator -avd Pixel_API_28_AOSP
To run React Native in the currently-open emulator:
react-native run-android
To choose between multiple running emulators:
adb devices
react-native run-android --deviceId=DEVICE_ID
(Last point from this answer)
Elaborating on #alexander 's answer, you can use the following workflow:
cd android
./gradlew assembleDebug # assembleRelease for release builds
adb install -s <yourdevice> app/build/outputs/apk/yourapk.apk # You can check the identifier for your device with adb devices
adb reverse tcp:8081 tcp:8081 Will forward the phone's 8081 port to the computer's 8081, where the packager listens. If you are deploying over Wi-Fi, have a look at: https://facebook.github.io/react-native/docs/running-on-device-android.html#configure-your-app-to-connect-to-the-local-dev-server-via-wi-fi
In a different screen, run:
npm start # Will run the packager
If you really need this, you might want to wrap the first snippet into a script that you can parametrize with your phone's identifier.
npx react-native run-android --deviceId='myDeviceId'
This works for me. don't forget '' this one. it accepts string
May be we can not select which android device attached to run.
Read from official react native website:
You must have only one device connected at a time.
You don't need to use run-android command to start it on specific device
Firstly, you have to start the packager:
./packager/packager.sh
Then just build an APK file and run it on target device. APK will connect to the build server, and fetch bundle from it automatically.
But if it didn't happen by some reasons, click on reload button :-)
If you're using React >= 0.68.x. Just type this:
npx react-native run-android --deviceId=VCR4XCORPFTKAQFA
VCR4XCORPFTKAQFA is recovered typing adb devices in your terminal.
To run the app on one specific connected android device:
Disconnect/Unplug all connected android devices.
Connect/Plug the device you want to install the app in
Run adb devices on your terminal to see the list connected devices (you should only see 1 such device as rest were disconnected)
Run npx react-native run-android
This will install the React-native app on the connected device via usb.
Actually, first of all, be sure about adb installation which I think while setting up your RN environment you have it for sure, follow these steps:
Connect your Android external device to your computer with a cable
Run this command adb devices and you will see the result at least:
List of devices attached
9999xxx3434yyy device
FYI: the 9999xxx3434yyy is your device id
Put the given device id in the following command
npx react-native run-android --deviceId="9999xxx3434yyy"
or
yarn run react-native run-android --deviceId="9999xxx3434yyy"
HINT: If the device is a Xiaomi product keep watching the phone screen because you should grand install access.
When 2 or more devices are connected
There seem to be no way to install app on a specific device in this scenario. So follow this
Disconnect all devices except one
run the command, in my case its react-native run-android
Now connect another device
repeat 2nd point
when done with every device, connect all and see device ids adb devices
now map device's port 8081 to computer's 8081
Eg:
adb -s DEV_1_ID reverse tcp:8081 tcp:8081
adb -s DEV_2_ID reverse tcp:8081 tcp:8081
adb -s DEV_3_ID reverse tcp:8081 tcp:8081
...