Ionic-cli: Bug console.log function does not work on Android device, ionic test 2 RC3

Created on 24 Nov 2016  路  8Comments  路  Source: ionic-team/ionic-cli

Short description of the problem:

This console.log function work with running on 'ionic serve' the browser show console.log.

But running on 'ionic run android -lc' or 'ionic run android' --livereload --consolelogs' not work console logs on android device.

What behavior are you expecting?

Using Ionic 2 RC2 the console.log function works from the android device, with the update to RC3 stopped working.

Steps to reproduce:

  1. run: ionic serve (this will work fine for console.log)
  2. run: ionic run android -lc (this will not work fine for console.log)
  3. run: ionic run android --livereload --consolelogs (this will not work fine for console.log)
  4. 4.
constructor(public navCtrl: NavController) {
    /**
     * This console.log function work with running on 'ionic serve'
     * the browser show console.log.
     * 
     * But running on 'ionic run android -lc' or 'ionic run android' --livereload --consolelogs'
     * not work display console logs on android device.
     */
    console.log('Constructor Home Page');
  }

testConsole() {
    /**
     * This console.log function work with running on 'ionic serve'
     * the browser show console.log. Event click button.
     * 
     * But running on 'ionic run android -lc' or 'ionic run android' --livereload --consolelogs'
     * not work display console logs on android device. Event click button.
     */
    console.log('Click on button Test Console Log');
  }

Post the output of ionic info below please

sebaxtian@Satellite [ test ] >> sudo ionic info

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v5.12.0
Xcode version: Not installed

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

This is my project, https://github.com/sebaxtian/ionic2-angular2/tree/master/test using the console.log function in the home.ts file

home.ts file: https://github.com/sebaxtian/ionic2-angular2/blob/master/test/src/pages/home/home.ts
home.html file: https://github.com/sebaxtian/ionic2-angular2/blob/master/test/src/pages/home/home.html

package.json file: https://github.com/sebaxtian/ionic2-angular2/blob/master/test/package.json

1. run: ionic serve (this will work fine for console.log)
1d

2. run: ionic run android -lc (this will not work fine for console.log)
2d

Most helpful comment

[SOLVED]

Change in the package.json file:
Replace: "ionic:serve": "ionic-app-scripts serve"
With: "ionic:watch": "ionic-app-scripts watch"

"scripts": { "ionic:build": "ionic-app-scripts build", "ionic:watch": "ionic-app-scripts watch" }

Change in the package.json file
1d

All 8 comments

[SOLVED]

Change in the package.json file:
Replace: "ionic:serve": "ionic-app-scripts serve"
With: "ionic:watch": "ionic-app-scripts watch"

"scripts": { "ionic:build": "ionic-app-scripts build", "ionic:watch": "ionic-app-scripts watch" }

Change in the package.json file
1d

I think you should reopen the bug, the problem should not be the app/script but the ionic cli. With 1.2.8 the log does work well.

I think this issue should be reopen as well. What I'm experiencing is as follow:

  1. If I run ionic run android -lc with an UNmodified package.json the live reload works well but the logs won't show up

  2. If I run ionic run android -lc with a Modified package.json the console logs will show up but the livereload won't work anymore

  3. If I run ionic run android --livereload --consolelogs both livereload and consolelogs work as expected, however it won't detect that it's running in a device

anybody else is having this behaviour?

Hi @tonirilix, I tried a lot but I can't reproduce your scenario, also --livereload --consolelogs dosn't work for me. But I can not do run because I brooked my android phone, so it's always only a emulating device.

You can see here
https://github.com/driftyco/ionic-cli/issues/1695#issuecomment-265353928

and here
https://github.com/driftyco/ionic-app-scripts/pull/492#issuecomment-265353659

where we discuss this

Thanks a lot @mburger81. I'll be following that thread.

Can you test as described in my links if installing ionic@test (2.1.15) is resolving the issue for you? Are you on ionic-angualr RC.3?
Please join first link/issue

Yes, I'm using ionic RC.3.
I just tried ionic@test (2.1.15) in an clean project and it's not resolving the issue for me.

I'll join now.

I was experiencing this issue and sebaxtian fix solved the issue.

Was this page helpful?
0 / 5 - 0 ratings