cordova run (in real) android device using command line?
Solution 1
You can force the run on device like this
cordova run android --device
If you get an error message like "No devices found" then make sure that you have developer mode and USB Debugging enabled on the device and also run
adb kill-server
and then adb devices
should list your device and cordova run android --device
should work
For iOS you can run from macOS
cordova run ios --device
If it doesn't work, make sure you have ios-sim
and ios-deploy
installed and that you have your development certificate and a wildcard provisioning profile on your machine.
You can open the .xcworkspace
file on /platforms/ios/ and Xcode will help you to create the certificates and provisioning profiles when you try to run the app.
Solution 2
If a real device is connected to your pc and it is recognized as well, you ca just use
cordova run android
and the app will start on your device. It worked for me.
Solution 3
you can do
cordova run android
as documented here.
That did not work for me for some reason. so what I did was copy the apk to the device. install it. and use chrome's remote debugging . by goint to chrome://inspect
in chrome.
Toni Michel Caubet
Front end developer and wordpress lover; based in Mallorca, Spain. Founder @ Funcook
Updated on December 04, 2020Comments
-
Toni Michel Caubet over 3 years
According to the documentation
We can run our android project on an emulator by:
cordova run android
orcordova emulate android
But how to run a project on a real android device?
thanks a lot
-EDIT-
adb devices
list none.. -
Toni Michel Caubet over 9 yearsthanks for writing, the thing is that if run this command, the emulator is executed..
-
Txugo over 9 yearsyes I had the same issue. I think because the target api was 19 instead of 21 (lolypop). check my updated answer for a plan B.
-
Toni Michel Caubet over 9 yearsI tried, but an error installing the .apk on the device. Do I have to set up somthing first? thanks!
-
Toni Michel Caubet over 9 yearsSorry for the delay
ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: ERROR: Failed to deploy to device, no devices found. Error: /Users/toniweb/Proyectos/cordova/funcook/platforms/android/cordova/run: Command failed with exit code 8 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:753:16) at Process.ChildProcess._handle.onexit (child_process.js:820:5)
-
jcesarmobile over 9 yearsThen the problem is your computer doesn't recognize the device. If you are using windows you have to install drivers (from google or de device vendor)
-
Toni Michel Caubet over 9 yearsI am actually using Mac OS, and I have the
htc
software included... any thoughts? -
jcesarmobile over 9 yearsdo you have the developer options activated on your phone? and the usb debuggin?
-
Toni Michel Caubet over 9 yearsYes to both, and
adb devices
list none.. ¿? -
jcesarmobile over 9 yearsthen that's the problem. maybe this helps stackoverflow.com/questions/7135999/…
-
Toni Michel Caubet over 9 yearsI just needed
adb kill-server
andadb devices
, it listed the device andcordova run android --device
runned on the device, thanks! -
d512 over 6 yearsFor me, it wasn't enough to enable developer mode. I also had to turn on USB Debugging inside the developer settings.
-
jcesarmobile over 6 years@d512 thanks for the note, it happened to me the other day on a new device, I think USB Debugging was automatically enabled when you enabled Developer settings, but it isn't enabled now
-
Enrique René almost 4 yearsI'm using cordova 9.0.0 and
--device
flag is needed to run in android device, in this case.