Android的Ionic --prod版本因ngc而失败

时间:2018-03-16 07:47:45

标签: android angular cordova ionic-framework ionic3

我正在尝试构建我的应用程序的prod版本并运行命令

ionic cordova build android --prod因以下错误而失败:

Running app-scripts build: --prod --platform android --target cordova
[19:55:39]  build prod started ...
[19:55:39]  clean started ...
[19:55:39]  clean finished in 10 ms
[19:55:39]  copy started ...
[19:55:39]  ngc started ...
Error: Error encountered resolving symbol values statically. Expression form not supported (position 133:13 in the original .ts file), resolving symbol App Module in ../src/app/app.module.ts
    at positionalError (..\node_modules\@angular\compiler\bundles\compiler.umd.js:23471:35)
    at simplifyInContext (..\node_modules\@angular\compiler\bundles\compiler.umd.js:23314:27)
    at StaticReflector.simplify (..\node_modules\@angular\compiler\bundles\compiler.umd.js:23328:13)
    at StaticReflector.annotations (..\node_modules\@angular\compiler\bundles\compiler.umd.js:22794:60)
    at NgModuleResolver.resolve (..\node_modules\@angular\compiler\bundles\compiler.umd.js:13352:70)
    at CompileMetadataResolver.getNgModuleMetadata (..\node_modules\@angular\compiler\bundles\compiler.umd.js:13937:60)
    at addNgModule (..\node_modules\@angular\compiler\bundles\compiler.umd.js:22526:58)
    at ..\node_modules\@angular\compiler\bundles\compiler.umd.js:22537:14
    at Array.forEach (native)
    at _createNgModules (..\node_modules\@angular\compiler\bundles\compiler.umd.js:22536:26)
[19:55:44]  copy finished in 4.78 s

即使我跑ionic cordova build android --prod --verbose,也会出现类似错误。

现在按照第一个错误行 - .. Expression form not supported ( position 133:13 in the original .ts file), resolving symbol App Module in ../src/app/app.module.ts它只有

export class AppModule {}

因此,我不知道错误的原因!!!

我跑的时候 ionic cordova build androidionic cordova build android --debug

它会在20秒内生成APK。

如何使用--prod标志运行build命令

我在本地安装的Ionic详细信息如下:

ionic info

cli packages: (C:\Users\***\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v6.9.1
    npm               : 3.10.8
    OS                : Windows 7

Environment Variables:

    ANDROID_HOME : ....\Android\android-sdk

Misc:

    backend : legacy

0 个答案:

没有答案