How to see errors from an ionic app from my device - android

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

Related

React native Cannot connect to react-devtools using android simulator

I execute the project with react-native run-android and in another terminal, i do:
npm run react-devtools
and it opens the new window of electron that says:
The react native app it will open in a few seconds...
but nothing happens.
I put in the simulator toggle inspector with Ctrl + m and i can see in networks that it makes a request to http://localhost:8097 and the result is it fails to connect and keeps trying with the same result.
The window of electron that is open it says that it wait connections to the port 8097 so i can see is trying to connect but with no results!
You need to run this command in a new terminal adb reverse tcp:8097 tcp:8097
react-devtools v4 is incompatible with react-native
try version 3 instead of version 4:
npm install -d -g react-devtools#3.x, it's worked for me.
The answer by #Unemployed3494 didn't work for me. Instead I killed all running processes belonging to my Mac OS user with this command:
pkill -u username
After doing so, react devtools connected as expected to the simulator.

React Native app: cannot connect to dev server, but the simulator is running - why?

The image describes my current situation properly. Please have a look at it first.
I am running my app on React Native. I have Android simulator on. I give the command to start the app. The app build finishes, but it says that virtual device not found, and in my simulator, if I open the app manually, it says that it cannot connect to Development server. It shows some issues.
Can anyone help?
Try run react-native run-android to connect your app to the emulator
Check USB Debugging is on(mostly running on virtual devices)
Check how you created project(react-native-cli or Expo) and run relevant app run command
Make sure your development server(node.js) is running when you run app. Sometimes it crashes then you have to again run command to run app
If all the step does not solve your issue try to uninstall app from device and run app again. Since react-native is still developing and its wired sometime these tricks works
I was having the same issue in Ubuntu 16.04. In my case the problem was that node packager wasn't running.
To check is packager is running easily you can open the browser and enter
http://localhost:8081/
You must see "React Native packager is running."
If you dont, then you can start packager from console running
react-native start
If you get an error like
" ERROR watch /your/project/path/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-ru ENOSPC"
Then run first
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Then run react-native start again and press the letter R twice in the emulator to reload.
Looking at the screenshot, seems like you don't have adb installed because there is a clear 'adb: not found error'.
Luckily Android studio ships with adb and is present in platform-tools under your Android SDK. (generally in /home/your-user-name/Android/Sdk/)
You only need to use it. Create a symbolic link in '/usr/bin/' or '/usr/local/bin/' depending how you'd like to use it.
Run the command:
sudo ln -s ~/Android/Sdk/platform-tools/adb /usr/local/bin/
After this run the app.

Is it possible to read logs in CLI when running Ionic app on Physical Android Device

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

How to run command 'ionic run android' on specific device?

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.

debug android app with ionic- cordova

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

Categories

Resources