4

I am new to ionic and I am trying to run a sample app of ionic on my phone (Samsung Galaxy s4) and I am unable to do so. I already have "USB Debugging" on in Developer Options.

As seen above even though my phone is connected it runs on emulator. The app works on emulator without an issue

When I do

$ionic run android

In logs says:

No target specified and deploying to emulator

The emulator comes up and has no issues in running the app.

Then I tried

$adb devices -l

Its shows my device XXX listed there

Now I try running

$ionic run --devices

Its says : Unknown platform : XXX

I tried

$ionic run -d 'XXX'

It throws error

CordovaError: Unknown platform : XXX at cli .....

I even tried by defining a run config file specifying the target, however the results are similar. It throws error at q.js throw e;

Target 'XXX' not found, unable to run project.

Can somebody please advise what step I have missed?

Firouziam
  • 777
  • 1
  • 9
  • 31
user1126937
  • 51
  • 1
  • 1
  • 5
  • Update your SDK, i remember some issue like that and was solves when i download and update android 4.4.4, i dont know why, but for me works – Max Pinto Aug 10 '15 at 02:12
  • @Max Pinto. Thanks for replying but I don't see an option of android 4.4.4 on my SDK Manager. After Android 4.4.2 (API 19), I see android 4.4W.2(API 20) and then Android 5.0.1 (API 21) and so on. – user1126937 Aug 12 '15 at 01:43
  • Thanks @Max Pinto for the idea. My android version is 4.4.4 and looking around on google it should be using the API 19. I was running with Android 5.1.1 ( API 22 ). Once I changed to run with target android version as 19 it worked. – user1126937 Aug 12 '15 at 02:31
  • i am also facing the same issue on oneplus A3003 device.. – ojus kulkarni Oct 12 '16 at 20:21
  • 1
    **Did you get the answer?** – Morteza QorbanAlizade Nov 13 '16 at 07:37

3 Answers3

0

Hi first check your android-manifest.xml file of target android version if it is 22 means you need to download android sdk of 22.0 than your problem will solve

Anil kumar
  • 930
  • 7
  • 18
  • Thanks Anil for replying. I did check my project's android-manifest.xml and its target version is 22. In my sdk manager I see following installed for Android 5.1.1 (API 22) 1) SDK Platform 2) Samples for SDK 3) ARM EABI v7a System Image 4) Intel x86 Atom_64 System Image 5) Intel x86 Atom System Image 6) Google APIs. Am I missing anything? – user1126937 Aug 12 '15 at 01:46
  • Thanks Anil for the idea. Setting the target version to 19 worked. More explanation @Max Pinto's post above – user1126937 Aug 12 '15 at 02:31
  • No you installed everything correctly ... check the android-manifest.xml file of target android version if it is 22 don't change it run the program and check whether it is working perfectly.. if it show's error just try to solve it or send it to me i will try to solve it .. otherwise change the android target version to -19 @user1126937 – Anil kumar Aug 12 '15 at 05:07
0

For run in andorid device write command:

$ ionic cordova emulate android

$ ionic run android --target=<device_id>

where device_id is the code obtained with

$ adb devices

Reference

Hope this may help you

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
0

First make sure you've installed cordova, latest at the time of writing is 8.0.0
$ cordova -v

Once it is installed connect your device enable debugging in developer option, if it's first time it might ask approve RSA key accept/ok it.
then run command
$ ionic cordova run android --device

make sure you made path setting with respect to android studio in Environment Variables.

with below command you can clean cache
$ npm cache clean --f

Shashank Pujari
  • 159
  • 1
  • 7