The instructions for how to run a react-native project on an android device is located at: https://facebook.github.io/react-native/docs/running-on-device-android.html
After determining your USB device, the instructions state to do the following command:
echo SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev" |
sudo tee /etc/udev/rules.d/51-android-usb.rules
The problem is that there is not a /etc/udev directory on my Mac. So obviously this fails.
Apparently MacOS doesn't support udev.
So how do I get this to work? If I ignore the udev part and use the command react-native run-android then it wants to run on an emulator. I experimented with --variant and just adding the values from adb devices, but no success.
--edit--
I should note that adb devices works fine, so does lsusb. The phone prompted to trust the computer, so I know that debugging is setup correctly. Just trying to figure out how to tell react-native to launch the app on the device (instead of an emulator).
Related
I run this command:
tns run android --emulator
And I get this error:
Cannot find connected devices.
Emulator start failed with: Cannot run the app in the selected native emulator. Try to restart the adb server by running the adb kill-server command in the Command Prompt, or increase the allocated RAM of the virtual device through the Android Virtual Device manager. NativeScript CLI users can try to increase the timeout of the operation by adding the --timeout flag.
To list currently connected devices and verify that the specified identifier exists, run 'tns device'.
To list available emulator images, run 'tns device --available-devices'.
I tried adb kill-server and that didn't help; I also tried the timeout thing with a setting of 60 and that didn't help either. I'm not sure how to access Android Virtual Device Manager to increase the allocated RAM. If I run tns device --available-devices I get a list of two emulated devices. How can I get the emulator set up so I can run my app?
Thanks! :)
This is a twin of this question (originally for iOS).
I would like to deploy and debug my Ionic app to an Android device connected via WiFi and not via USB with my PC, that is a device that I can reach just with WiFi.
Is this possible?
Yes, of course there is, provided that:
you have Chrome installed
you can plug-in your device via USB just ONCE.
If you can, in Windows you do like this
install ADB by executing this as administrator saying yes (Y) to everything
add ADB path to env variable (usually ADB is installed in the root so you do PATH=%PATH%C:\adb;)
install a bash emulator
USB plug-in the phone
open the bash emulator and execute in order
ID=$(adb devices | awk -F'device' '{if (match($0, /device$/)) print $1}');
IP=$(adb shell ifconfig wlan0 | awk '{if (sub(/inet addr:/,"")) print $1 }');
adb tcpip 5555;
adb connect $IP:5555
now you can deploy the app just using the regular ionic cordova run android --device: Ionic will deploy the app on the last device configured on points 6-9.
For the same reason you can debug on Chrome simply by navigating chrome://inspect, and click on the device with the IP equal to that of point 7.
I have found most of these information here. Thanks Remy Sharp
Try to connect the device and the pc on the same network.
Then run ionic run android —device -lc
I don’t remember if you have to plug your device at least once for the build and then you can unplug and debug with WiFi maybe it’s not necessary.
I'm having huge problems with Titanium Alloy on Windows 10. I am using the Atom editor to write my apps. Whenever I execute ti build, enter the command up to 10(!!!) times until an Android device can be found.
For the Android emulator I get an error message as follows:
[Error] Failed to install apk on "emulator-5554"
[Error] Error: device not found
I tried the commands ti build -p android, ti build -p android -T emulator and ti build -p android -T emulator -C emulator-5554 --log-level info. I also tried starting the emulator manually from avd.exe. I deleted the AVD and created a new one, too
When a device (USB debugging enabled) is connected, i tried ti build -p android -T device and ti build -p android -T device -C XT1032, where XT1032 is the name of the device. I get an error message as follows:
[ERROR] Unable to find any devices
I didn't try so far if the device will be found after some more tries.
When executing the commands, I tried all 4 combinations:
emulator off, device disconnected
emulator off, device connected
emulator on, device disconnected
emulator on, device connected
I uninstalled Titanium, Android SDK, NodeJS and Java and deleted all folders of them. I removed all registry entries, too. Then I installed everything again, Titanium at last. Same problem.
I am using Java 32 bit (v8.0.1020.14), NodeJS v4.2.6 (also tried v6.3.0, but v4.2.x is recommend), Android SDK (SDK Tools v25.1.7, SDK Platform-tools 24.0.1 and SDK Build-tools 21.1.2. I also tried SDK Build-tools 24.0.1, but 21.x.x is recommend) and Titanium (SDK v6.0.0.v20160719180254, CLIv5.0.9).
I modified my environment variables as follows:
PATH:
C:\android-sdk\tools;C:\android-sdk\platform-tools;C:\android-sdk\ndk-bundle;C:\Program Files (x86)\Java\jdk<version>\bin
JAVA_HOME:
C:\Program Files (x86)\Java\jdk<version>
ANDROID_SDK_HOME:
C:\android-sdk
I had to set ANDROID_SDK_HOME and C:\android-sdk\ndk-bundle, otherwise the NDK and the AVDs wouldn't be found by ti setup check.
Here is a screenshot of ti setup check: link to image
I don't know why https://www.google.com is unreachable. Furthermore, Intel HAXM is installed. I even reinstalled it without success. The previous installation of Titanium could find it...
Thanks for your help!
TLDNR: my Titanium Alloy installation has problems finding devices. It only works from time to time without any obvious pattern
The process terminates after building the APK file. If the emulator is running, it is possible to manually install the APK. Use this command in the Command Line:
<Android SDK folder>\platform-tools\adb.exe -s emulator-5554 install -r -d <project path>\<project folder>\build\android\bin\<project name>.apk
The project name is equal to the project folder name. After installing the APK, the application can be started manually in the emulator.
Nonetheless, there are still a lot of issues when developping on Windows 10... I think this forces me to switch to a MAC.
I'm trying to run android emulator with the command tns run android. This starts the emulator but it keeps stuck on Android logo and I get the following error:
(...)
BUILD SUCCESSFUL
Total time: 17.013 secs
Project successfully built.
Using C:\(...)\sample-Groceries\platforms\android\build\outputs\apk\sampleGroceries-debug.apk
Starting Android emulator with image Nexus6
Waiting for emulator device initialization..............
Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb
server with 'adb kill-server' command. Alternatively, run the Android
Virtual Device manager and increase the allocated RAM for the virtual
device.
(...)
Here is my Android Virtual Device configured:
AVD Manager
Note: I can run the application on my phone anyway, but not on my PC.
Finally I found the problem.
In Android Virtual Device Manager, there was an error I didn't see:
AVD Manager error
Here is a solution which I found to be useful.
enter image description here
You just have to manually activate the emulator, which you can do using android studio or command line. Using the command line, you have to run this command
emulator -avd avd_name [ {-option [value]} … ]
for ex:
/Android/sdk/emulator/emulator -avd test
Once the emulator starts you can run this command
tns run android
I started having similar issue after updating to the latest Android Studio and latest emulators. I switched the VM Heap to 64, and it worked for me. May be worth giving that a try.
Open your Android Virtual Device Manager and download the latest
emulator. That will fix the error.
I had the same problem. I fixed that by:
Open emulator manually from Android Studio (double-click on position in AVD Manager list)
Run tns run android
Works for macOS Sierra.
After I upgraded to Yosemite and upgraded to Xcode 7.1 I cannot start the adb server. Both of which I don't see why they would affect adb. When I type adb devices or adb start-server in the terminal I get:
cannot bind 'tcp:5037'
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
There are no adb processes running that I can see in activity monitor.
I've checked with lsof -i tcp:5037 that there are running processes on port 5037.
I have the latest Android SDK.
I have checked that my .bashrc loads the correct Android SDK and adb.
I've tried to adb kill-server and then adb start-server several times, but when I run start-server I get the error message that I cannot bind tcp:5037.
I've tried deleting .android folder and unplugging/plugging in my android phone, toggling on/off USB-debugging and revoking debugging authorizations.
Android studio cannot start adb anymore as well.
I've tried restarting the computer.
I'm not running Genymotion.
None of the above worked, and I'm about to give up. I've checked every stackoverflow thread about this issue and none of the mentioned fixes have worked so far.
Success.
Oddly enough, adb worked again after I upgraded Yosemite to El Capitan (10.11).