29

I am using Sencha Touch 2.3.1 for developing cross platform application and to deploy it to native platforms I am using Cordova 3.3.0

I followed this tutorial. Following the tutorial I was able to run the .apk file in the emulator. Now I want to run the application on my device. Even though I connect my device to the laptop using a usb, I am not able to run the application on my device. Any help will be appreciated.

user3213851
  • 1,068
  • 2
  • 12
  • 24

3 Answers3

63

To have the project run on your device instead of in the emulator, you basically only have to plug in your device before you run cordova run android.

Cordova will run the emulator only if it can't find a device connected.

Before you run cordova run android, I advise you to run the command adb devices to check if your device is found by the android sdk tools.

If it's not, you need to enable USB debugging on the device and install an adb driver for your device.

Edit:

As this answer seems to get up votes, I think it would be a good idea to improve it a little...

There's actually a --device option you can add when you run cordova run android to force to start on the device (without that an emulator is started if no device is found, that can sometime be annoying).

QuickFix
  • 11,661
  • 2
  • 38
  • 50
  • 2
    it worked when i added `--device` to the command, like this `cordova run android --device` – Hirdesh Vishwdewa Jul 22 '15 at 14:05
  • 3
    If this doesn't work, try killing the server `adb kill-server`, disconnect your android device from USB, start the server `adb start-server` and reconnect the device. The above answer should then work. – achabacha322 Feb 11 '16 at 04:01
  • 1
    you enable USB debugging mode by going to the settings on the Android device, tap the build number seven times, then it should show `now you are a developer` and then enable USB debugging in the developer settings. – SCBuergel Mar 03 '16 at 22:16
  • I have USB debug on and I have an adb driver set up, but I still can't "cordova run android --device" it. At a loss for what the problem could be. – dav Jul 21 '17 at 14:58
  • do you see your device if you run `adb devices` in a shell? If not, then you have to fix this (maybe enable debug on device or allow the computer for debug?) If yes, maybe there's a mess in the android tools used by cordova (With recent versions of cordova and android sdk being replaced by android studio there may be some path issues finding the tools) – QuickFix Jul 21 '17 at 18:46
-1

You should go to cordova/platforms and check if there is ios or android folder depending on what you want to run the app. If the folder is not there you should add it from the command line like so:

cordova platform add android

or

cordova platform add ios

of course I am assuming you have the cordova command line utilities installed

EDIT:

once you've got the project folder for the platform you need you can open the project using Eclipse, IntelliJ or xCode depending on your platform. Once you've got it opened in the IDE you should be able to install it on your device. Note that the process is different for each IDE - Eclipse, IntelliJ, xCode ( btw you can also use Android Studio for android apps )

Also to be able to install it on an Android phone you need to enable USB Debugging from your settings.

Petar Vasilev
  • 4,281
  • 5
  • 40
  • 74
-3

take that .apk file instal in your device. you will get your apps.

Sport
  • 8,570
  • 6
  • 46
  • 65
  • 1
    yeah this is fine for one time purpose. But i need to test my app again and again in this device. And I dont think taking the apk and installing in the device is a very good idea. I need to directly run the apk in my device. – user3213851 Jan 29 '14 at 05:43
  • 3
    That makes no sense. You need to either scan the qr code when using phonegap build service or manually download the apk on the device. Alternatively you can run `cordova run android --device` which will install and run the app on the device for easier testing – DATEx2 Apr 16 '14 at 21:24