Ionic 2 app takes 20-25 seconds in smartphone to load app


#1

first of all i add android platform by writing command in cmd as cordova platform add android --save

but after successfull adding platform i build apk and when i open in smartphone it takes 20-25 sec to load

what should i do please suggest me i am beginner in ionic 2


#2

When you build the app, remember to add --prod at the end of the command. What command are you using to build?


#3

i am writing only
cordova platform add android --save in cmd


#4

That’s not building, that’s just adding the platform. How do you run the app on your device?


#5

and after adding platform
i click on build app icon in android studio


#6

@mich356c please suggest me


#7
ionic cordova build android --prod

or run instead of build. If run doesn’t work, you need to find the apk file it says it created after running build.


#8

you mean after adding platform i have to run in cmd ionic cordova build android --prod ?


#9
 Build
 ionic cordova build --release android
generate keytool
 keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
sign the jar
 jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-   unsigned.apk alias_name
zipalign
zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk

#10

Some usefull commands:

Create the project

ionic start myApp

Add platform

ionic cordova platform add android

Development build

ionic cordova build

Production build

ionic cordova build --prod

Run development version to device

ionic cordova run android --device

Run production version to device

ionic cordova run android --device --prod

Serve to browser

ionic serve

If you want to publish the app in Play Store, follow instructions wroted by @yuvanesh:


#11

@mich356c

after running ionic cordova build android --prod
i got this error

  • Running command [15:17:21] lint finished in 2.58 s
    × Running command - failed!
    [ERROR] An error occurred while running cordova build android (exit code 1):

      ANDROID_HOME=C:\Users\PC\AppData\Local\Android\sdk
      JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
      Error: Could not find an installed version of Gradle either in Android
      Studio,
      or on your system to install the gradle wrapper. Please include gradle
      in your path, or install Android Studio

#12

after running ionic cordova build
i got this error

ANDROID_HOME=C:\Users\PC\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
Error: Could not find an installed version of Gradle either in Android
Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio


#13

Then you need to fix that first.


#14

i am beginner in ionic 2 mobile development

can you please give me suggestion that how to fix it ?


#15

You already have the answer:


#16

i already installed android studio latest


#17

Hi, @cooldp007

First you configure Android sdk in your system and update your Gradle

sudo apt-get install gradle

Hop, this will solve your issue

Thanks,


#18

dear ,
i have windows pc


#19

ANDROID_HOME=‘D:\Android\sdk’

JAVA_HOME=‘C:\Program Files\Java\jdk1.8.0_131’


#20

@cooldp007

Could you update your Android SDK