I am facing some problems with the release version of the apk, these problems happen only with the release version while the debug version works perfectly.
Cordova plugins not loaded always when you close and open the app different times.
Ionic Deploy not injected and it’s always undefined.
first of all thank you for your solution. I am facing the same problem
When you run the command
ionic build android --prod
what is your debug print saying? … look at this:
a dev build is started and NOT a production build… do you have the same output or is your app building in production?
I think the production build is causing the messed up release-apk.
Not a problem, this seems not to be a quite common problem some people might have some might not, I have also opened a bug on the ionic app script repo, hoping that someone will take care of it!
This issue is related with the building process and each ionic app script version has its own problem.
First it’s better if you update the app script to version 1.0.1 or to the latest, both have the same error but at least you will have a smallest binary.
npm install @ionic/app-scripts@latest --save-dev
This is what I have done:
npm run ionic:build
ionic build android --release
Sign the apk after that.
After some testing I figured it out that the flags --prod and --aot make the bundle unstable.
Hello guys. @7728, @anthem182. I’m trying build my app for production but get same error ionic-app-script’s "Cannot read property ‘codeGen’ of undefined
TypeError: Cannot read property ‘codeGen’ of undefined
at Object.doCodegen "
I built for debug version and it worked perfectly. I’m using ionic-app-scripts 1.3.5.
Can anyone help me?
I faced the same issue. I did not find any solution for that. So what i did I created a new project and used my “src” folder in that, after that you have to change app.module.ts file and some tweaks in the code to make it running on newer version, as the newer version will be using angular 4.
Once you will do that you will be able to create the prod apk with in 2 to 3 mins (It was taking 15 mins earlier for me).
Or you can directly update the “package.json” file with the updated version of angular cli and other modules.
Also be sure that when building for production the code doesn’t have any wrong call or reference to variable and functions. Sometimes it compiles in debug but fails in prod.