ionic cordova build android difference between - ionic-framework

Please Explain me difference between:
ionic cordova build android -> .apk Slowin loading
ionic cordova build android --prod -> .apk Fast in loading
ionic cordova build android --prod --release -> .apk Slow in loading
Thanks

Without flags it generates the apk debug version. And with release it generates the apk ready for the store but unsigned when you sign it you can upload it.
The --prod flag:
This will minify your app’s code as Ionic’s source and also remove any debugging capabilities from the APK.

Related

how to do prod build in ionic capacitor

In ionic 4, how to do a release aka prod build?
The angular part can be build in prod mode by ionic build --prod
Now how to copy this build to android? If I do ionic capacitor run android it will do normal build first and then copy assets to android. But I want to build in prod mode and take assets to android.
(I know how to generate apk in Android studio)
After doing
ionic build --prod
Assuming you have already installed Capacitor, otherwise you can follow this and thereafter,
You can do the following
npx cap copy android
Which copies the built code to android folder.
Then you can do
npx cap open android
Which opens android studio if you havent opened it already, then you should go to Build -> Generate Signed Bundle / APK option and the rest is quite straightforward.
More info can be found here
You can use the simple way.
ionic capacitor build android --prod
after the command, the android studio will open automatic
Development:
android stdio: Build-> Build Bundle(s)/APK(s)->Build APk(s)
Production: android stdio: Build-> Generate Signed Bundle(s)/APK(s)-> Android App Bundle or APk-> release

ionic app error while building Android APK

I am getting the error while building the ionic app ,ionic-app-script is missing.How to add 'ionic-app-script' file in ionic 2 project? what is the purpose of this file?
just delete platform folder and run
ionic cordova build android --release --prod

How can I install my ionic app on my android phone?

I'm trying to install my ionic app on my android phone. I tried
install my ionic app on my android phone
The app ran on my phone, but when I ran the same command to run a different app, the app was replaced on my mobile. How can I keep both? I don't intend to modify any of these apps, they are ready. I tried these commands as well:
ionic cordova build android --prod --release
and
ionic cordova run android --prod --release
I got this error message:
[ERROR] An error occurred while running cordova run android --release
(exit code 1)
By default, it will overwrite the previous version. You can keep the both app using below way:
Check the config.xml file, and change the id of the app.
<widget id="new.app.id" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
Now, it will be considered as a different app and will not replace the previous one.

How to reduce app size in Ionic2?

I am new to Ionic, recently I developed One app.But my app size was 8mb.
How should I reduce app size,and I am not using any Images and plugins also, but it took 8mb size. please help me.
For production builds you can use ionic cordova build [android/ios] --prod --release. This can reduced the size of your application.
The prod and release flags will minify code and remove debugging utilities.
Documentation: https://ionicframework.com/docs/intro/deploying/#production-builds
You can use one of $ ionic cordova build options
--no-build - Do not invoke an Ionic build
--prod - Build the application for production
--aot - Perform ahead-of-time compilation for this build
--minifyjs - Minify JS for this build
--minifycss - Minify CSS for this build
--optimizejs - Perform JS optimizations for this build
...
For example: ionic cordova build android --prod --aot

Ionic 2 Android Production Build loads very slow

I have finished my Ionic 2 App for Android.
For testing I generated my builds with:
cordova build android
These APKs work but the device ready event takes quite a while to fire. No problem.
No I build the productions APK:
cordova build --release android
And the device ready event still happens only after a few seconds. I hoped that this would not be the case in the production version.
ionic run android --prod
This creates a build for debugging and in this build the device ready events fire very fast. But the build is called app-debug.apk.
How can I build a production build that loads fast?
For production (the --prod uses aot which makes load time faster). Also make sure to use ionic middleware instead of cordova
ionic build --release --prod android
To debug in aot:
ionic run android --aot