The latest versions of ionic 2 rc0 and angular 2 have errors when building Android (NGC: error: error encountered when statically parsing symbol values)
•
Android
An error occurred when I used the ionic build Android command to build Android
NGC: error: an error was encountered while statically parsing the symbol value. Reference the local (not exported) symbol "dictionary". Consider exporting the symbol (position 14:8 in the original. TS file), and resolve the symbol translation_ PROVIDERS
My code in the translation.ts file
export const TRANSLATIONS = new OpaqueToken('translations');
// all traslations
const dictionary : any = {
[LANG_EN_NAME]: LANG_EN_TRANS,
[LANG_AR_NAME]: LANG_AR_TRANS,
[LANG_FR_NAME]: LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS : any = [
{ provide: TRANSLATIONS, useValue: dictionary},
];
My app.module.ts code
import {TRANSLATION_PROVIDERS,TranslatePipe,TranslateService} from './translate';
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
],
providers: [TRANSLATION_PROVIDERS,TranslateService ]
})
export class AppModule {}
Any suggestions on this issue, by the way, when I use ion services to order my project to work 100%
resolvent:
I found a solution
You don't have to export dictionary objects, just change the key to a static value
This works for me:
// all translations
const dictionary = {
"en": LANG_EN_TRANS,
"ar": LANG_AR_TRANS,
"fr": LANG_FR_TRANS
};
// providers
export const TRANSLATION_PROVIDERS = [
{ provide: TRANSLATIONS, useValue: dictionary },
];
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码