There is a way to debug?
I use
ionic run android
command to run the app on android but then - how can I see console.log() messages?
Thanks
If you run your app in the livereload mode you will see the console.log() messages. You can start it like this:
ionic run android -l
You can also use chrome developer tools like it would be a normal webpage. Here is good description how you achieve that: Remote Debugging on Android with Chrome
Connect with an android device which has Android OS version >= 5
Enable developer option from the settings. This procedure varies from device to device. In addition you must enable USB debugging mode from developer option or from other section of your device.
If you get any error like “Your device is not connected” from Android SDK or Android studio then find out the problem from your device manager of pc. Most of the time appropriate driver or driver is not installed in the machine. Download it and follow my instruction in a video (Yafi Tech).
Run the command ionic cordova run android. APK is built and installed in the device. done
run “chrome://inspect” in the chrome status bar. Remote debugging of connected device has been started.
Now run the installed application and operate from the device or chrome.
Click on inspect of WebView. For debugging Go to the console of browser if you want to trace out any error.
you can also watch video here
Now that there is a livereload option (-l), to see the console.log messages you have to use -c or --consolelogs
But to have logs, the livereload option is required so :
ionic run android -lc
See the documentation for more options :
http://ionicframework.com/docs/v1/cli/run.html
The Ionic CLI has been updated for ionic 2+ to deploy app in live reload mode use the following command.
Synopsis
$ ionic cordova run <platform> <options>
Example
$ ionic cordova run android -l -c
Make sure that you have installed the latest version of Ionic/Cordova CLI
with Ionic 5 and cordova 9 use:
ionic cordova run android -l --consolelogs
where -l is for livereload
If you want a real debug, with watches, step into, etc, try the Cordova Tools extension for Visual Studio Code
The page constains the instructions for debuging on device.
Connect your android device to computer/laptop and simply run below command
ionic cordova run android --device -l --debug
From ionic doc
ionic run ios [options]
http://ionicframework.com/docs/cli/run.html
Related
I've built an app using ionic2 + cordova, now I am trying to run this in a real device. I have already set up all the things I had to, such as: %JAVA_HOME%, %ANDROID_HOME%, %ANT_HOME% and all the paths as well. However, as I try to run the command: ionic cordova run android, I recevive this error: "CORDOVA IS NOT A VALID TASK".
When I run: "ionic run android" I get this another error: "No emulator images (avds) found, if you would like to create an
avd follow the instructions provided here:
http://developer.android.com/tools/devices/index.html
Or run 'android create avd --name --target '
in on the command line."
Please, I am new in the mobile world, so I thought about starting a small POC, but I am not even being able to run this in my cellphone. Could someone help me out in this issue? I would appreciate it
ADB only recognizes Android devices, and in order for it to recognize your device you need to enable Debugging Mode on the Developer Settings of the device. Check out this tutorial.
I got an issue on meteor JS on my windows 10, I have installed android studio and Java 8 JDK. On my meteor project I tried to build an android by typing meteor install-sdk android, but I got an error of This command is not yet available on Windows. .. Does anyone have an idea about this?
I know this was posted a year ago, but I found a fix recently, just in case anybody gets stuck on this and needs help.
It's from this link: https://github.com/meteor/meteor/issues/4155#issuecomment-384105563
But I'll repost the solution with a few extra changes I had to make by myself.
Basically you need to install Android studio and run it to get the Android SDK, install the Java JDK, and install Cordova. After this you can add the android platform to meteor.
Steps:
Install Android Studio
Run Android Studio once for download, full installation, and accept terms
Update npm with npm i npm
Run npm install cordova -g (-g flag for global install)
Run meteor npm i -g write-file-atomic path-is-inside async-some dezalgo
Run meteor add-platform android
After doing this, you should be able to run meteor run android-device to run on your Android device using a USB cable.
NOTE:
If you are connected to a WiFi network while running meteor run android-device, you might get an error similar to this:
Error detecting IP address for mobile app to connect to:
Found multiple network interfaces with non-internal IPv4 addresses:
'some IP address', 'some IP address'
Please specify the address that the mobile app should connect
to with --mobile-server.
To fix this, modify the command to:
meteor run android-device --mobile-server <ip.of.my.device>
Of course, ensure your PC and Android device are on the same WiFi network.
Go to Settings>About Device>Status to get your current IP Address on your Android device.
The app will now be installed on your phone over the WiFi connection.
(It might take a while though)
Hope this helps.
Cheers.
Fellows I have made an app by using ionic framework.
When I run
ionic serve
On the terminal it runs as it should be. But when I run it via:
ionic run
I see on the device the app running by displaying the ionic's loading screen, but after that it does not run as it should be.
What I am asking is how can I see - debug any sort of error from the app running on the device in order to figure out what's wrong?
I am using an Adroid device for the tests.
Try this :
ionic run android -c -l
// -c for consolelogs and -l for livereload
After ionic run android command keep fixed to your cable and laptop.
Go to your chrome and type chrome://inspect you can see your app in that and click inspect so that you can able to look what is going on in your mobile app and you can debug it.
You can add additional flags when using ionic run.
-c will show console logs.
-s will show server logs.
-l will perform live reload of the application when code changes.
So you can use something like
ionic run android -cls
Note that for livereload to work if the device is not connected directly make sure its in the same network as the serving device. Make sure to serve to a local IP address in this case (you can use ionic address to change that).
I fixed it by running:
adb logcat | grep 'Web Console'
On a linux terminal / git bash
I'm trying to build an Android app using Ionic framework. I'm able to see the logs generated in the browser. But is there any way to get the logs in CLI when running the app in Android physical device instead of an emulator?
Connect your device with the USB cable. In Cli run command adb logcat
There is actually a way to see the same logs (as you would when in the browser) when running the app on the actual device by running the app with ionic like this:
ionic run android -l -c
-l switch is for livereaload
-c switch is for console logs
I have 2 devices detected in adb. One from my genymotion, and the other from my real device :
$ adb devices
List of devices attached
192.168.57.101:5555 device
e78ab88d device
I want to run my ionic app on e78ab88d device. How can i achieve this?
If i run ionic run android, its automatically run on my genymotion device. It says, no target specified.
img no target specified
What command to run on specific device?
run with target device id, something like :
ionic run android --target=e78ab88d
EDIT
With new Ionic 3 CLI use :
ionic cordova run android --target=e78ab88d
For list of all available devices, use :
ionic cordova run android --list
try this command may help you
ionic run android --e78ab88d
Using --target=e78ab88d failed for me. But it seemed to work when I used --device=e78ab88d.
Basically I have 2 Android phones connected and I wanted to target a specific device. without the --target or --device, it deployed randomly to the devices.
ionic cordova run android --device=e78ab88d worked for me. Just in case someone is experiencing the same problem as me.
to also run the app live do.
$ionic cordova run android -l
make sure that the phone is connected with laptop through cable.