Ionic-cli: Console.logs not working when using android emulator (v3)

Created on 28 Apr 2017  路  15Comments  路  Source: ionic-team/ionic-cli

What version of the CLI are you using? Output of ionic --version

3.0.0-beta9

Short description of the problem:

Run ionic cordova emulate android -c This only opens emulator and installs the app. Does not maintain the ionic-cli terminal as livereload does hence no connected terminal that can output console.log values.

What behavior are you expecting?

The ionic-cli terminal remains connected to emulator. Any value entered in console.log to be printed on the command line terminal.

Steps to reproduce:

  1. Ensure cordova-plugin-console is installed
  2. Run ionic cordova emulate android -c

Post the output of ionic info below please
npm (global):

@ionic/cli-utils : 1.0.0-beta0
cordova          : 6.5.0
ionic            : 3.0.0-beta9

npm (local):

@ionic/app-scripts              : 1.3.4
@ionic/cli-plugin-cordova       : 1.0.0-beta0
@ionic/cli-plugin-ionic-angular : 1.0.0-beta0
Ionic Framework                 : ionic-angular 3.0.1

System:

Node       : v6.10.2
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed

Most helpful comment

@ylacast
I find an alternative way to see console.log().
I use the chrome device inspector.
When emulator is ready and app lunch go to this address in Chrome : chrome://inspect/#devices
Then you should find your device in the Remote Target section and you can inspect it.
Then a new window open and you can now inspect console log in dev console tools in Chrome.
With option -l for livereload when you modify the code of your app the emulator and chrome reload too.
Sorry for my bad english.

All 15 comments

Please try with the livereload flag:

ionic cordova emulate android -l -c

i tried with the flag too but none of the console logs appeared

Same probleme here !!

with new sidebar template project and this code in home.ts in class HomePage :
ngOnInit(){ console.log("coucou"); }

Command :
ionic cordova emulate android -lcs

Starting logs :
Starting app-scripts server: --livereload --consolelogs --serverlogs............

ionic info :
global packages:

@ionic/cli-utils : 1.0.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.0.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.0.0
@ionic/cli-plugin-ionic-angular : 1.0.0
Ionic Framework                 : ionic-angular 3.2.1

System:

Node       : v7.10.0
OS         : Linux 4.4
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed

`

@msitruk Send full output please.

@dwieeb
$ ionic cordova emulate android -lcs
Starting app-scripts server: --livereload --consolelogs --serverlogs --address 0.0.0.0 --port 8100 --livereload-port 35729 --iscordovaserve --externalIpRequired --nobrowser - Ctrl+C to cancel
[08:51:47] watch started ...
[08:51:47] build dev started ...
[08:51:47] clean started ...
[08:51:47] clean finished in 1 ms
[08:51:47] copy started ...
[08:51:47] transpile started ...
[08:51:49] transpile finished in 2.09 s
[08:51:49] preprocess started ...
[08:51:49] deeplinks started ...
[08:51:49] deeplinks finished in 15 ms
[08:51:49] preprocess finished in 16 ms
[08:51:49] webpack started ...
[08:51:49] copy finished in 2.25 s
[08:51:55] webpack finished in 6.45 s
[08:51:55] sass started ...
[08:51:56] sass finished in 916 ms
[08:51:56] postprocess started ...
[08:51:56] postprocess finished in 4 ms
[08:51:56] lint started ...
[08:51:56] build dev finished in 9.53 s
[08:51:56] watch ready in 9.58 s
[08:51:56] dev server running: http://localhost:8100/

cordova emulate android
ANDROID_HOME=/home/maxime/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Subproject Path: CordovaLib
[08:51:58] lint finished in 1.58 s
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

at build_1dm00es4cj4p2vhsaw7ijt353.run(/home/maxime/GitHub/meteo/platforms/android/build.gradle:137)

The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild
UP-TO-DATE
:preDebugBuild
UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders
UP-TO-DATE

:CordovaLib:compileDebugShaders
UP-TO-DATE
:CordovaLib:generateDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugAssets
UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
UP-TO-DATE
:CordovaLib:packageDebugRenderscript
UP-TO-DATE
:CordovaLib:compileDebugRenderscript
UP-TO-DATE
:CordovaLib:generateDebugResValues
UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources
UP-TO-DATE
:CordovaLib:processDebugManifest
UP-TO-DATE
:CordovaLib:generateDebugBuildConfig
UP-TO-DATE
:CordovaLib:processDebugResources
UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard
UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE
:CordovaLib:processDebugJavaRes
UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders
UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
UP-TO-DATE
:CordovaLib:bundleDebug
UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary
UP-TO-DATE
:prepareDebugDependencies

:compileDebugAidl

UP-TO-DATE
:compileDebugRenderscript
UP-TO-DATE
:generateDebugBuildConfig

UP-TO-DATE
:generateDebugResValues
UP-TO-DATE
:generateDebugResources
UP-TO-DATE
:mergeDebugResources

UP-TO-DATE
:processDebugManifest

UP-TO-DATE

:processDebugResources

UP-TO-DATE

:generateDebugSources
UP-TO-DATE

:incrementalDebugJavaCompilationSafeguard

UP-TO-DATE

:compileDebugJavaWithJavac

UP-TO-DATE

:compileDebugNdk

UP-TO-DATE

:compileDebugSources UP-TO-DATE
:mergeDebugShaders

UP-TO-DATE
:compileDebugShaders

UP-TO-DATE
:generateDebugAssets

UP-TO-DATE
:mergeDebugAssets
UP-TO-DATE
:transformClassesWithDexForDebug
UP-TO-DATE

:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug
UP-TO-DATE
:processDebugJavaRes UP-TO-DATE

:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug

UP-TO-DATE
:assembleDebug
UP-TO-DATE
:cdvBuildDebug
UP-TO-DATE

BUILD SUCCESSFUL

Total time: 2.023 secs
Built the following apk(s):
/home/maxime/GitHub/meteo/platforms/android/build/outputs/apk/android-debug.apk

ANDROID_HOME=/home/maxime/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
No emulator specified, defaulting to Nexus_9_API_23

Waiting for emulator to start...

sh: 1: glxinfo: not found
Waiting for emulator to boot (this may take a while)...
BOOT COMPLETE

Skipping build...

Built the following apk(s):
/home/maxime/GitHub/meteo/platforms/android/build/outputs/apk/android-debug.apk

Using apk: /home/maxime/GitHub/meteo/platforms/android/build/outputs/apk/android-debug.apk

Package name: io.ionic.starter
INSTALL SUCCESS

LAUNCH SUCCES`

@dwieeb any new ? it's very hard to dev without console.log exept through adb logcat

Hi guys, any news on this issue ? Thanks !

@ylacast
I find an alternative way to see console.log().
I use the chrome device inspector.
When emulator is ready and app lunch go to this address in Chrome : chrome://inspect/#devices
Then you should find your device in the Remote Target section and you can inspect it.
Then a new window open and you can now inspect console log in dev console tools in Chrome.
With option -l for livereload when you modify the code of your app the emulator and chrome reload too.
Sorry for my bad english.

This works perfectly, thanks a lot @msitruk !
You saved my day :)

I can confirm this! No console.log output to the terminal...

My ionic info:

cli packages:

@ionic/cli-plugin-cordova       : 1.5.0 (/Users/big-r/Documents/Developer/ma-thesis-fsu-cm/prototype/file/node_modules/@ionic/cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (/Users/big-r/Documents/Developer/ma-thesis-fsu-cm/prototype/file/node_modules/@ionic/cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (/Users/big-r/Documents/Developer/ma-thesis-fsu-cm/prototype/file/node_modules/@ionic/cli-utils)
ionic (Ionic CLI)               : 3.6.0 (/Users/big-r/Documents/Developer/ma-thesis-fsu-cm/prototype/file/node_modules/ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node       : v8.1.3
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 6.0.0 
npm        : 5.3.0

I have the same problem, since upgrading to ionic cli3

Make sure @ionic/app-scripts is up to date. I believe I fixed it here: https://github.com/ionic-team/ionic-app-scripts/commit/8e644077a1a5da49bc914778205badfa809024f6

console.warn and console.info work fine !
console.log and console.debug do not

@ylacast
I find an alternative way to see console.log().
I use the chrome device inspector.
When emulator is ready and app lunch go to this address in Chrome : chrome://inspect/#devices
Then you should find your device in the Remote Target section and you can inspect it.
Then a new window open and you can now inspect console log in dev console tools in Chrome.
With option -l for livereload when you modify the code of your app the emulator and chrome reload too.
Sorry for my bad english.

What are you supposed to do when you go to this link? I see my emulator listed, but there's nothing to click and doing Ctrl+Shift+I doesn't show debug statements either.

Same happens to me. I see my device but can't click any thing to go to the devtools or see console.

Victor

@ylacast
I find an alternative way to see console.log().
I use the chrome device inspector.
When emulator is ready and app lunch go to this address in Chrome : chrome://inspect/#devices
Then you should find your device in the Remote Target section and you can inspect it.
Then a new window open and you can now inspect console log in dev console tools in Chrome.
With option -l for livereload when you modify the code of your app the emulator and chrome reload too.
Sorry for my bad english.

What are you supposed to do when you go to this link? I see my emulator listed, but there's nothing to click and doing Ctrl+Shift+I doesn't show debug statements either.

Was this page helpful?
0 / 5 - 0 ratings