Ionic cordova构建android -prod -release失败,无法解析' ./ app.module.ngfactory

时间:2017-12-02 08:40:48

标签: angular cordova ionic-framework ionic2

我正在使用Ionic 3.当我尝试cordova build android --prod --release时,构建完成,但签名的APK在启动后显示白屏。当我尝试ionic cordova build android --prod --release时,它显示以下错误。

enter image description here

Main.ts



import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

platformBrowserDynamic().bootstrapModule(AppModule);




app.module.ts



import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
import { AppRate } from '@ionic-native/app-rate';
import { PopoverPage } from '../pages/popover/popover';

import { TabsPage } from '../pages/tabs/tabs';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { LoginPage } from '../pages/login/login';

import { PostService } from './app.postservice';
import { UrlService } from './app.service';
import { GetService } from './app.getservice';
import { AppVersion } from '@ionic-native/app-version';
import { SlidersPage } from '../pages/sliders/sliders';


@NgModule({
  declarations: [
    MyApp,
    TabsPage,
    LoginPage,
    SlidersPage
  ],
  imports: [
    BrowserModule,
    HttpModule,
     IonicModule.forRoot(MyApp,{
       tabsHideOnSubPages: true
     })
    
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    LoginPage,
    SlidersPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    AppVersion,
    AppRate,
    
    BarcodeScanner,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    {provide: PostService, useClass: PostService},
    {provide: UrlService, useClass: UrlService},
    {provide: GetService, useClass: GetService},
  ],

})
export class AppModule {}




离子信息给出了

cli包:(C:\ Users \ akrra \ AppData \ Roaming \ npm \ node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

全球套餐:

cordova (Cordova CLI) : 7.1.0

本地包裹:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 6.3.0 windows 5.0.0
Ionic Framework    : ionic-angular 3.9.2

系统:

Node : v9.2.0
npm  : 5.5.1
OS   : Windows 10

环境变量:

ANDROID_HOME : not set

其他:

backend : legacy

1 个答案:

答案 0 :(得分:3)

Ionic Cli在使用--prod选项运行时似乎遇到报告正确错误的问题。投掷"无法解决' ./ app.module.ngfactory'"而不是正确的错误消息。

正在跟踪herehere

Ionic Dan Bucholtz 的开发人员提出了一种解决方法,可以检索实际的错误消息here

  

与此同时,要查看应用程序中的错误并修复它们,请尝试运行:

./node_modules/.bin/ngc

您可以运行上述命令来确定应用中的真正问题。