Ngc error: Compilation failed - ionic build android

Hi,
When I tried to “ionic build android”, I got this error:
[16:34:07] ngc error: 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 168:19 in the original .ts file), resolving symbol AppModule…
ngc error: Compilation failed
[16:34:07] NGC encountered an error

Can anyone help me pls?

3 Likes

Hi @hqho, I had same issue with my project.

[12:20:22]  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 27:19 in the original 
            .ts file), resolving symbol AppModule in /client/.tmp/app/app.module.ts 
[12:20:22]  ngc failed 
[12:20:22]  ionic-app-script task: "build" 
[12:20:22]  Error: Error 

It was something wrong in my app.module.ts on line 27 (my translate module). In Browser I had no error, but on build It failed.

My import part was like this.

imports: [
    IonicModule.forRoot(MyApp),
    BrowserModule,
    HttpModule,
    TranslateModule.forRoot({ 
      provide: TranslateLoader,
      useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'),
      deps: [Http]
    })
  ],

I had to move to

imports: [
    IonicModule.forRoot(MyApp),
    BrowserModule,
    HttpModule,
    TranslateModule.forRoot({ 
      provide: TranslateLoader,
      useFactory: (createTranslateLoader),
      deps: [Http]
    })
  ],

And to add the function

export function createTranslateLoader(http: Http) {
  return new TranslateStaticLoader(http, './assets/i18n', '.json');
}
1 Like