6

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.

3
  • you need to paste the error in your question.not an external image Commented Dec 27, 2017 at 6:56
  • I have not authority to insert image inside question. Commented Dec 27, 2017 at 8:04
  • I meant the error text Commented Dec 27, 2017 at 8:05

3 Answers 3

11

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
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, Mr. David Dal Busco. I have removed audio-category.module.ts from the project and this working fine. Thanks a lot
Hello I am facing the same error, I deleted the xxx.module.ts but again the issue came in yyy.module.ts file. Please help
5

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

1 Comment

:sir its not possible for me because i am using lazy loading in my app so any another way to fix above issue?
0

I had this issue too.

And surely the solution is to delete the pagename.module.ts files and inside the page.ts file delete the @IonicPage tag.

However on nested pages DO NOT delete the .module.ts files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.