Debug on Emulator and Device


#1

With RC.3 we are not able to debug anymore on emulator or device.

So with ionic emulate android -lc we see no console.log on shell and also we can not see errors or anything else.
We think this was working fine with older app/script.

Also we are asking us why you removed all the documentation on how run ionic2 on emulator or device?

There is also a issue on app/script for that:


#2

You can solve this by downgrading the ionic cli
npm i -g ionic@2.1.8


#3

Do we need also to configure scripts in package.json

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

Reverting to ionic 2.1.8 and running ionic emulate android -lc we get this error

[12:13:27] Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider
replacing the function or lambda with a reference to an exported function (position 62:23 in the original
.ts file), resolving symbol AppModule in
/abcdefghijklmnop/.tmp/app/app.module.ts
[12:13:27] ngc failed
[12:13:27] ionic-app-script task: “build”
[12:13:27] Error: Error

npm ERR! Linux 4.8.0-27-generic
npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “run” “ionic:build” "–"
npm ERR! node v5.12.0
npm ERR! npm v4.0.2
npm ERR! code ELIFECYCLE
npm ERR! abcdefghijklmnop@0.0.1 ionic:build: ionic-app-scripts build
npm ERR! Exit status 1

This is a bug we already saw before in an other module on build jar, but we resolved it, with ionic 2.1.8 we have it in app.module.ts which we don’t have on latests ionic version.

We also are not sure what does the error mean, the only function we do in app.module.ts is on import IonicModule.forRoot(MyApp)


#4

I’ve never encountered this error,
I’m using app-scripts 0.0.46 along with CLI 2.1.8
However i don’t emulate, i just run it on a device


#5

The problem above is, we can not call a function in declaring a provider, the only strange thing is, on some versions it works and on other version it does not work.
So we changed this

@NgModule({
        .....
        providers: [
            {
                 provide: HttpService,
                 useFactory: (backend: XHRBackend, options: RequestOptions, platform: Platform, toastCtrl: ToastController)  => {
                       return new HttpService(backend, options, platform, toastCtrl);
                 },
                 deps: [XHRBackend, RequestOptions, Platform, ToastController]
            }
        ]
});

to this:

export function httpFactory(backend: XHRBackend, options: RequestOptions, platform: Platform, toastCtrl: ToastController) {
  return new HttpService(backend, options, platform, toastCtrl);
}

@NgModule({
        .....
        providers: [
            {
                 provide: HttpService,
                 useFactory:  httpFactory,
                 deps: [XHRBackend, RequestOptions, Platform, ToastController]
            }
        ]
});

using CLI 2.1.8 the console log is now back! Does someone know? Is this a bug or is this wanted.


#6

CLI 2.1.8 is a workaround for enabling logging but with this versione the -livereload does not work.
@mazastairs can you confirm that?


#7

Yup, livereload won’t work. You have to choose between console.logs or fast building. This is really annoying, but the only solution i found for the moment.


#8

But do you know, does the team know this or plan to resolve this?


#9

There is another issue in the ionic-cli for that,