Ionic 2 app starting with white space and delay - ionic-framework

I have developed ionic 2 calendar app. when start this app via phone it gets white screen for a while like 1 min first and take more time to start my app. How to solve this issue.

Try running the app in production mode to speed up and optimize the start of your application
If you're in an ionic 2 app, you can enable this by doing the following,
open src/app/main.ts
Import enableProdMode from Angular 2 core
import {enableProdMode} from '#angular/core';
import { AppModule } from './app.module';
Then call the enableProdMode() function before bootstraping your module
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
and now while running the app through cli try adding a flag like "--prod"
ionic run android --prod
In ionic 3.x, you don't have to enable anything in the code. you can simply run it using the cli command,
ionic cordova run android --prod
check this documentation from angular.io
Hope that helps

Related

Debugging Ionic 4 App in Appium WebdriverIO not working : WebView missing

I am trying to debug an Ionic 4 app using Appium & WebdriverIO. I am receiving feedback that I need to enable Webview in my app in order for this to work. The problem is I cannot find a single reference as to how to do this in Ionic anywhere.
I have also attempted to run my app in Browserstack where for the same reason, it won't run at all.
Can someone from Ionic comment on the correct approach to this, that will work for Android and iOS platforms, based on the same Ionic code.
The solution comes in a few steps.
1 - Enable Webview
In the config.xml file, make sure you set the following:
<preference name="WKWebViewOnly" value="true" />
This has the effect of setting :
<application
android:debuggable="true"
2 - Debug Build
In addition to point 1, note that for a production release build, we use the command :
$ ionic cordova build android --prod --release
However, Android does something clever behind the scenes in that this build can only be debugged locally for security reasons. So, no matter what you do, when you try and run this up in Browserstack, it will not provide webview as a context. We fix this by using the debug build flag:
$ ionic cordova build android --prod --debug
3 - Bonus Bug
Unfortunately, there is a bug in the Android Debug build process. So there is one more step to cover. You have to run zipalign twice when you're working on the debug build. Don't ask me why! You just do...
Debug > "%ANDROID_HOME%\build-tools\28.0.3\zipalign" -f 4 app-debug.apk temp.apk // zip-align
Debug > "%ANDROID_HOME%\build-tools\28.0.3\zipalign" -f 4 temp.apk SensorNode.apk // need to do it twice because of android bug!!!
Debug > "%ANDROID_HOME%\build-tools\28.0.3\apksigner" sign --ks my-release-key.jks --v1-signing-enabled true --v2-signing-enabled true SensorNode.apk

Issue when I use ionic cordova run android

I am getting an issue when I try to run with command line
ionic cordova run android
The error that it diplays is this one:
ERR_NO_TARGET: No targets devices/emulators available. Cannot create AVD because there is no suitable API installation. Use --sdk-info to reveal missing packages and other issues.
But the thing is that I created a device in the Android Studio:
so I wonder what could the problem be? Thanks
You need to launch the emulator and keep it running before executing the command ionic cordova run android
Click on the Play icon in the Virtual Devices list to launch the emulator.
Might not be the answer you're looking for but generally, I use:ionic cordova build android
Then open the platform/android directory in Android Studio.
Maybe you should try this :
for see avaliables devices this:
ionic cordova run android --list
for run android app on device this:
ionic cordova run android --device --verbose
i hope help you.
Make sure you have the following variables set in your environment.
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_AVD_HOME=$HOME/.android/avd

How to update my apk every time I make changes on my template or code changes?

How to update my apk every time I make changes on my template or code changes.
You can use the livereload feature of ionic cordova emulate or ionic cordova run to run the code on an emulator or device and see the changes live as as you code.
Here's how with the emulator:
ionic cordova emulate android --list to get a list of available emulator targets to copy into the next command.
ionic cordova emulate --livereload android -- --target="[TARGET]"
See the CLI docs for more info.
You can do livereload from a ionic cordova run <platform>, if it's an apk i assume that is for android so you can do this:
ionic cordova run android --livereload
For more options like specific port you can take a look on the docs

Ionic 2 application take too much to launch on android device each and everytime.?

I already try this command : ionic build android --prod --release but still same result. How can one reduce the launching time of an ionic 2 application?
Check the plugins, there must be a problem with some plugin that would give error and increase loading time.
Add lazy loading in some components or upgrade ionic version3+ which brings angular 4

ionic: Starter app with -v1

I am getting started with Ionic. I want to use ionic 1. I am using following command to create ionic v1 app as explained here.
ionic start -v1 myapp blank
But it's creating ionic v2 app using angular 2. I don't know why it is doing so. I also tried commands below but no luck.
ionic -v1 start myapp blank
ionic start myapp -v1 blank
ionic start myapp blank -v1
It's not showing any error or warning either. Can anyone please help? Thanks.
You need to downgrade your ionic version. Then run "ionic start myproject blank" without --v
The current way of doing this is using the --type=ionic1 option:
ionic --version # 3.8.1
ionic start test blank --type=ionic1