ionic cordova build android failed due to AOT

15,785

Solution 1

I recently had this issue, I will post my solution in case someone else needs it.

1 - Remove @IonicPage() from .ts files

2 - Delete .module.ts

Solution 2

First I gonna past here the missing screenshot you linked:

enter image description here

Then, about the solution, the error msg tells you what's the problem respectively your AudioCategoryPage is contained in two modules, therefore:

  • Are you using lazy loading? Remove AudioCategoryPage from app.module.ts

or

  • Are you not using lazy loading? Remove (delete) audio-category.module.ts
Share:
15,785
Sagar
Author by

Sagar

Working inside browser...

Updated on June 23, 2022

Comments

  • Sagar
    Sagar about 2 years

    I am new to ionic. I have created new application using the ionic framework. But when I hit command ionic cordova build android --prod --release build failed with AOT exception..

    Everything working fine if I hit command ionic cordova build android --release without --prod flag.

    Error Message:

    $ ionic cordova build android --prod --release Running app-scripts build: --prod --platform android --target cordova [14:03:18] build prod started ... [14:03:18] clean started ... [14:03:18] clean finished in 2 ms [14:03:18] copy started ... [14:03:19] deeplinks started ... [14:03:19] deeplinks finished in 47 ms [14:03:19] ngc started ... [14:03:27] typescript error Type AudioCategroyPage in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.ts is part of the declarations of 2 modules: AppModule in C:/xampp/htdocs/study-baba-beta/src/app/app.module.ts and AudioCategroyPageModule in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.module.ts! Please consider mo ving AudioCategroyPage in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.ts to a higher module that imports AppModule in C:/xampp/htdocs/study-baba-beta/src/app/app.module.ts and AudioCategroyPageModule in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.module.ts. You can also creat e a new NgModule that exports and includes AudioCategroyPage in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.ts then import that NgModule in AppModule in C:/xampp/htdocs/study-baba-beta/src/app/app.module.ts and AudioCategroyPageModule in C:/xampp/htdocs/study-baba-beta/src/pages/audio-categroy/audio-categroy.module.ts.

    Error: The Angular AoT build failed. See the issues above
    at C:\xampp\htdocs\study-baba-beta\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
    at step (C:\xampp\htdocs\study-baba-beta\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (C:\xampp\htdocs\study-baba-beta\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:5                                                     3)
    at fulfilled (C:\xampp\htdocs\study-baba-beta\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
    at <anonymous>
    [14:03:27]  copy finished in 9.27 s
    

    My Deployment Info. cli packages: (C:\Users\shaggy\AppData\Roaming\npm\node_modules)

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

    global packages:

    cordova (Cordova CLI) : 8.0.0
    

    local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2
    

    System:

    Node : v8.9.1
    npm  : 5.5.1
    OS   : Windows 7
    

    Environment Variables:

    ANDROID_HOME : not set
    

    Misc:

    backend : pro
    

    Please help me to solve this problem.

    Thanks in advance.