Testing your application on real devices


#1

Dear @max,

At the end of the first tutorial video LearnIonic you say that the best way to test/run your app would be if you connect a device.

Are there any guidelines/tutorials on how to do this, or is it just simply connect and run?

Thanks in advance!


My application not work on android 4.4.x, is that normal?
#2

connect your device by usb. Then on your CLI try typing adb devices if a device is listed, run cordova run android.
If nothing appears on adb devices, go to settings on your phone, developer settings, and activate developer mode and usb debugging. You may need to re-plug your device after activating those settings.

This way you can test your app directly on your device.
For iphone just plug and cordova run ios


#3

Thanks for you answer I’m going to try it.


#4

hi… Bonda it was not work for me, I attached my device and debug/usb conected fine, when I typing adb devices into command line showed : list of devices attached, thats all. When I run cordova run android have error no started emulator found, what happen ?


#5

Are you using window machine for development,if so What android device are you using? is your device is showing in file explorer? if not install the device driver ,for samsung devices samsung kies,or other manufacturer install respective device driver.if you done those you can try the adb commands

D:\AndroidWorkSpace\My>adb devices
List of devices attached
0123456789ABCDEF        device

It will show the connected devices.


#6

Hi, I’ve just documented how to view the console log on android:

Running logcat (see webview console log messages) on android

run ADB and get connected devices (first change dir to the android platform tools dir)

$ cd /Users/kevin/ADT/sdk/platform-tools

$ adb devices

List of devices attached
40CBA8038654 device

get PID (process ID) of app - first get all processes

$ adb -s 40CBA8038654 shell ps

then grep that (look for a string that identifies your app)
$ adb -s 40CBA8038654 shell ps | grep solomon (solomon being part of package name)
u0_a129 17099 151 363464 69256 ffffffff 00000000 S ie.solomon.myapp

$ adb -s 40CBA8038654 shell ps | grep 17099 (check for sub processes - so far i’ve found that the app runs as a single process)
u0_a129 17099 151 363464 69256 ffffffff 00000000 S ie.solomon.myapp

finally run logcat and filter by PID so you just see output from your app:

adb -s 40CBA8038654 shell logcat –v time | grep 17099

For IOS, I’ve found that once you have installed it via the USB, by doing cordova run ios, it will automatically provide a log

All this is on a Mac, but steps exactly same on Ubuntu (Linux). Of course IOS only works with a Mac


#7

Hi Thamil thanks for your direction yes I am using windows, now my device showed in explorer, and do adb devices it is LJNJZPNJWWQ84AM device show up! but when I did cordova run android, this is another ERROR: failed to launch application on device: ERROR: failed to install apk to device: pkg: /data/local/tmp/cordovaApp-debug.apk do you have idea?


#8

@vanbumi Great,I dont have the exact idea but. I Can suggest some tricks to find out the exact problem.

1.Manually copy your apk file to device /sd card or phone storage and install manually. if it is success it may be the problem in USB cable connection refer here


#9

Good man…! I will try it for sure, thanks I’ll let you know… :slight_smile:


#10

Hi there

I am trying to run this on a USB connected ios device (iPhone 5) and whenever I run ios it opens the simulator on my computer, and nothing happens on my iPhone. Is there a step I might have missed.

Any help would be much appreciated - I am trying to test bluetooth connectivity and from my simulator I am just seeing that bluetooth is not enabled. I think this is because I am not testing on a real device.

Thanks
Josh


#11

For iOS:
You need to build first the iOS-App

ionic build ios

Then go into your project folder and u see a “platforms” folder. In this folder u can see the platforms. Look in the iOS folder and open the xCode Project and then u can run your app on your iOS-Device.

INFO: You need a Provisioning-Profile, without this u cant build apps for your device!!!

For Android:
First look if you enabled Android-Development tool on your device. Then look in the Development-Tool, if USB-Debugging enabled!!!

After thees steps look into Security if is enabled to install apps from unknowns source.

If all enabled you can use in your terminal

ionic run android

Sorry for my bad english :S


#12

Thank you, I solved my problem.


#13

You can also deploy to an android device connected to your local WiFi network. On most custom ROMs wifi adb is already built in and can be added to Quick Settings menu. It can also be enabled via Settings > Developer options ADB over network. If you don’t have the corresponding option then you can use a third party app which will let you turn it on and off. See e.g. https://play.google.com/store/search?q=wifi%20adb

Once you enabled ADB over wifi on the phone note down its IP address (e.g. 192.168.1.123), and then from terminal run:

adb connect 192.168.1.123

Now you can deploy directly to your phone without a cable:

ionic run android

#14

HI.
when I run ionic run android in terminal to run app in real device, 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

I am using windows 8 and Huawei with Android 4.2.2

Help Me Please.


#15

adb devices just show emulator, not my connected device, why?


#16

Xactly worked fine …


#17

use this :

~ adb devices
~ adb kill-server
~ adb start-server
~ adb devices

you should now be able to see you’re connected device.


#18

Thank you. Yours method is working


#19

@vanbumi please uninstall your already installed app with same package name… then try to run.