0

I'm working on ionic App and I'm trying to run App on real Android device, But when I run ionic run android in terminal, I get the following error:

Running command: "C:\Program Files (x86)\nodejs\node.exe" D:\wamp\www\pars-app\pars-app\hooks\after_prepare\010_add_platform_class.js D:\wamp\www\pars-app\pars-app

add to body class: platform-android

ANDROID_HOME=D:\Sdk\android-sdk

JAVA_HOME=C:\Program Files\java\jdk1.8.0_45

No target specified, deploying to emulator

ERROR running one or more of the platforms: No emulator images (avds) found. 1. Download desired System Image by running: "D:\Sdk\android-sdk\tools\android.bat" sdk 2. Create an AVD by running: "D:\Sdk\android-sdk\tools\android.bat" avd HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver

You may not have the required environment or OS to run this project

How to prevent run app on windows emulator? I want to run app on real device that conected to my computer.

I am using windows 8 and Huawei with Android 4.2.2

::note I have read these questions, But I didn't got the answer!

Why not work Ionic app testing on android real device?

Ionic run android does not run app on device

ionic run android - configurations not running app on device

Community
  • 1
  • 1
Morteza QorbanAlizade
  • 1,520
  • 2
  • 19
  • 35
  • Did you install drivers for Huawei? – Tomislav Stankovic Nov 13 '16 at 11:33
  • @TomislavStankovic Yes, I did. – Morteza QorbanAlizade Nov 13 '16 at 12:00
  • Before running your app, try "adb devices" in your console. This command lists all devices currently connected and acknowledged by the Android Debug Bridge. If your device isn't listed in the command's output, try to unplug and plug it. Sometimes the service isn't started (which it will be then by the "adb" command), So after replugging your phone run "adb devices" again and it should show up. Then try running the app. – OClyde Nov 13 '16 at 12:16
  • @OClyde I did all you said, But my list of devices attached is empty – Morteza QorbanAlizade Nov 13 '16 at 12:26
  • So we tracked it down to being an Android problem! That's a progress I'd say! ;) So.. general questions would be: Have you enabled the developer mode on your Android phone? If so, have you enabled USB-Debugging in there? Those would be the first things to check coming into my mind right now! – OClyde Nov 13 '16 at 12:33
  • @OClyde Yes, I did all of them, but it's not working,I've also wonder!! – Morteza QorbanAlizade Nov 13 '16 at 13:11
  • Maybe MTP mode causes the problem, heard of it before though. Some devices only work in PTP mode, can be changed in Settings > Storage > more > USB Connection. Could you check if it works when in PTP? – OClyde Nov 13 '16 at 16:20
  • @OClyde My phone hasn't this setting, There isn't _more_ in _storage_ setting – Morteza QorbanAlizade Nov 14 '16 at 07:34
  • There might be a duplicate entry for "Storage" in the settings, have you looked for "Storage & USB"? Otherwise let's try a different approach: When connected to your PC, your phone should show a notification stating "Charge phone" or a similar notification stating that your phone is connected to your PC. Click this notification and you should be able to change the USB connection type! Then just try MTP and PTP, one setting should work out! ;) – OClyde Nov 14 '16 at 08:19
  • @OClyde No, There isn't _PTP_ mode! – Morteza QorbanAlizade Nov 14 '16 at 08:29
  • Mh.. not having the device in your hands makes it so much harder to solve such a problem - sorry though. However, could you please check this link, just to be sure that we talk about the same: https://topbullets.com/2014/12/20/how-to-disable-enable-usb-file-transfer-mtp-port-in-android-mobile-phone/ This link actually is specifically for Android 4.2.2. Also: Do you have Stock Android or do you use a ROM? – OClyde Nov 14 '16 at 08:36
  • @OClyde Thanks for your comments :) – Morteza QorbanAlizade Nov 14 '16 at 08:44
  • You're welcome! Did it work though? If so, then I would post this as an answer so you can mark it and we close this thread as intended by StackOverflow :) – OClyde Nov 14 '16 at 08:49
  • 1
    @OClyde Finally I succeeded, thank you :) – Morteza QorbanAlizade Nov 19 '16 at 10:19

2 Answers2

1

To make sure that your app is not installed to an emulator but to your device, take the following steps:

  1. Open up your console and run adb devices. This should give you a list of all devices available (real devices as well as running emulators) to the Android Debug Bridge. If the adb command is not recognized check that you have installed the Android SDK correctly and that you've set all the necessary environment variables accordingly.
  2. The adb devices command might give you output similar to this:

    * daemon not running. starting it now on port 5037 * * daemon started successfully *

    This indicates that the ADB wasn't ready before, so in this case just try to un- and replug your device and run adb devices again to see if the device is listed afterwards.

  3. If your device is still not showing, check that USB Debugging is enabled on your device. Therefore you first have to enable developer settings, which you can do by tapping the build number (Settings => About Phone) 7 times (no, that's not a joke ;) ). After that, you'll have the developer options in your settings menu. Open these and check "USB Debugging"

  4. If still your device isn't recognized by the ADB, change the USB connection mode. You can either do this in the developer options as well or tap the notification shown when the phone is connected to your PC. Try MTP as well as PTP, on of those should do the job.

After these steps, it should be nearly impossible that the device is still not recognized by your PC. As soon as there is a phone available, Ionic will install the app on the phone automatically instead of launching an emulator.

OClyde
  • 1,036
  • 6
  • 11
1

As a complement to @OClyde answer, you could try :

adb kill-server

adb start-server

To have infos about these commands :

adb --help

Nb : Sometimes, for a reason i do not know, the connection between my phone and the computer break. Running this fixes it.

littleboy
  • 78
  • 1
  • 5