arielfaur / ionic-audio

An audio player for Ionic 3 and Angular 4. Works with HTML 5 audio or native audio using Cordova Media plugin.
http://arielfaur.github.io/ionic-audio/2.0/index.html
MIT License
321 stars 163 forks source link

AoT compiler errors #94

Closed borodiliz closed 7 years ago

borodiliz commented 7 years ago

Ionic-audio version: [ X] 2.3.0

I'm submitting a ... [ X] bug report (probably but not sure if there is any workarround to solve this)

Current behavior:

When trying to compile using AoT I get the following error:

[13:26:16]  build prod failed: Error encountered resolving symbol values statically. Function calls are not supported. 
            Consider replacing the function or lambda with a reference to an exported function, resolving symbol 
            AppModule in /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts, resolving symbol AppModule in 
            /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts 
[13:26:16]  ionic-app-script task: "build" 
[13:26:16]  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, resolving symbol AppModule in 
            /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts, resolving symbol AppModule in 
            /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts 
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, resolving symbol AppModule in /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts, resolving symbol AppModule in /datos/borja/proyectos/myapp-app-v2/src/app/app.module.ts
    at simplifyInContext (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler-cli/src/static_reflector.js:475:23)
    at StaticReflector.simplify (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler-cli/src/static_reflector.js:478:22)
    at StaticReflector.annotations (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler-cli/src/static_reflector.js:60:36)
    at NgModuleResolver.resolve (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:14261:46)
    at CompileMetadataResolver._loadNgModuleMetadata (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:14646:45)
    at CompileMetadataResolver.getUnloadedNgModuleMetadata (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:14636:23)
    at addNgModule (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:12944:43)
    at /datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:12957:16
    at Array.forEach (native)
    at _createNgModules (/datos/borja/proyectos/myapp-app-v2/node_modules/@angular/compiler/bundles/compiler.umd.js:12956:28)

Expected behavior:

An application compiled with AoT

Steps to reproduce:

Just execute: ionic build android --prod --release

This is not happening when using ionic build android --dev

Related code:

I suspect the problem is on the dynamic initialization on ionic-audio.module.ts but I have no idea about how to fix this.

  static forRoot(audioProvider?: AudioProvider): ModuleWithProviders {
    let audioProviderInit = audioProvider ? 
      { provide: AudioProvider, useValue: audioProvider } : 
      { provide: AudioProvider, useFactory: audioProviderfactory };
    return {
      ngModule: IonicAudioModule,
      providers: [
        audioProviderInit
      ]
    };
  }

Other information:

Ionic info:

Cordova CLI: 6.5.0 Ionic Framework Version: 2.0.1 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.1.0 ios-deploy version: Not installed ios-sim version: Not installed OS: Linux 4.4 Node Version: v6.9.1 Xcode version: Not installed

Thanks man for this amazing plugin!

arielfaur commented 7 years ago

Hi @borodiliz, thanks for reporting this bug. I forgot to test for AoT, my bad. I will look into it. Thanks!

patwaswapnil commented 7 years ago

any update? I am getting it too.

arielfaur commented 7 years ago

Can you check the patch with version 2.3.1 I have just uploaded? I tried building locally with the --prod flag and it seems to work. I needed to make a small refactor of the module config for it to work. This is the setup now from your app.module.ts:

import { IonicAudioModule, AudioProvider, WebAudioProvider, audioProviderFactory } from 'ionic-audio/dist';

/**
 * Sample custom factory function to use with ionic-audio
 */
export function myCustomAudioProviderFactory() {
  return new WebAudioProvider();
}

@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    IonicModule.forRoot(MyApp),
    IonicAudioModule.forRoot({ provide: AudioProvider, useFactory: audioProviderFactory }), 
    // this uses the default built-in factory function,
    // or use your custom function above to force a specific provider
    // { provide: AudioProvider, useFactory: myCustomAudioProviderFactory }
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule {}
patwaswapnil commented 7 years ago

Worked 👍 , but without passing any object to IonicAudioModule.forRoot(). Thanks for the amazing plugin.

arielfaur commented 7 years ago

@patwaswapnil It should also work if you pass a provider object like this:

IonicAudioModule.forRoot({ provide: AudioProvider, useFactory: audioProviderFactory })

Have you tried that too?

patwaswapnil commented 7 years ago

@arielfaur , Yes i have tried that but while doing this a run time error occurs during init (.create is not a function), i don't have that exact error.

arielfaur commented 7 years ago

OK, I will look into that later. Thanks!

borodiliz commented 7 years ago

Hi all,

After upgrading to 2.3.1:

02-27 13:12:33.840 18931 18931 I chromium: [INFO:CONSOLE(45)] "Uncaught Error: Module build failed: Error: ENOENT: no such file or directory, open '/datos/borja/proyectos/my-app-v2/node_modules/ionic-audio/dist/ionic-audio-interfaces.js'
02-27 13:12:33.840 18931 18931 I chromium:     at Error (native)", source: file:///android_asset/www/build/main.js?ionicCachebuster=74117 (45)

Any ideas? Thanks in advance!

patwaswapnil commented 7 years ago

Get hint from here- https://github.com/driftyco/ionic-app-scripts/issues/632

Workaround for your issue-

make directory (eg. external) inside src directory. Copy ionic-audio directory from npm_module and paste inside created directory(external).

Edit tsconfig.json

"include": [ "src/**/*.ts", "external/**/*.ts" ],

borodiliz commented 7 years ago

Thanks @patwaswapnil but unfortunately your workaround is not working for me. @arielfaur maybe the right solution for this could be #97 ?

arielfaur commented 7 years ago

Hey! I am sorry for this but there is a total lack of documentation regarding component development. This lack of documentation and support is so discouraging sometimes. I don't have time now to keep trying different approaches but I will do as soon as I find some time.

sfaizanh commented 7 years ago

@borodiliz @arielfaur fixed it, Please confirm

Geroo commented 7 years ago

I am having a related issue with the latest ionic version:

"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@ionic/storage": "2.0.0",
"ionic-angular": "2.2.0",
"ionic-audio": "2.3.4"
"@ionic/app-scripts": "1.1.4"

Error:

[13:08:43]  build prod failed: Error encountered resolving symbol values statically. Calling function 'makeParamDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in
        C:/dev/git/test/app/node_modules/ionic-audio/node_modules/@angular/core/src/di/metadata.d.ts,
        resolving symbol OpaqueToken in
        C:/dev/git/test/app/node_modules/ionic-audio/node_modules/@angular/core/src/di/opaque_token.d.ts,
        resolving symbol OpaqueToken in
        C:/dev/git/test/app/node_modules/ionic-audio/node_modules/@angular/core/src/di/opaque_token.d.ts
sfaizanh commented 7 years ago

@Geroo for temporary workaround is to replace with "ionic-audio": "2.3.4" with "ionic-audio": "git://github.com/sfaizanh/ionic-audio.git#2.0" until @arielfaur merge #102 or fixes it

sfaizanh commented 7 years ago

@Geroo this for ionic 2.2.0 otherwise for ionic 2.1.0 use "ionic-audio": "2.3.4" it's working fine

bhlokhandwala commented 7 years ago

[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of date. Error: Error encountered resolving symbol values statically. Calling function 'providers', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol IonicAudioModule.forRoot in /Users/burhanuddinlokhandwala/Documents/office/illusion/pickup/node_modules/ionic-audio/dist/ionic-audio.module.d.ts, resolving symbol AppModule in /Users/burhanuddinlokhandwala/Documents/office/illusion/pickup/src/app/app.module.ts, resolving symbol AppModule in /Users/burhanuddinlokhandwala/Documents/office/illusion/pickup/src/app/app.module.ts

I have tried the above solution still getting this error.

sfaizanh commented 7 years ago

@bhlokhandwala which ionic version are you using and what version of ionic-audio also

thomdejong101 commented 7 years ago

@bhlokhandwala @sfaizanh I appear to have the same error these are my version numbers:

"@angular/common": "4.1.2",
"@angular/compiler": "4.1.2",
"@angular/compiler-cli": "^4.1.2",
"@angular/core": "4.1.2",
"@angular/forms": "4.1.2",
"@angular/http": "4.1.2",

"ionic-angular": "3.3.0",
"ionic-audio": "^3.0.2",

[16:24:36] ngc started ... [WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of date. Error: Error encountered resolving symbol values statically. Calling function 'providers', .....

I have tried looking around but haven't found anything that doesn't seem to be fixed in 3.0.2.