DEV Community

Cover image for Step-by-Step Guide to Building Your First Ionic App with Cordova on Windows
Sefat Anam
Sefat Anam

Posted on β€’ Edited on

3 3

Step-by-Step Guide to Building Your First Ionic App with Cordova on Windows

One Question - Did you noticed that building apk with cordova have smaller size rather than use capacitor ? know me your feedback !

How to build a Ionic app using Cordova in windows

Prequsites :

  1. Install Andorid studio, JDK (preferd version 1.8), gradle.

    Tricks
    
    After installed Android studio build a native hello world app and run it through Emulator or physical device for the first time. It will automatically gives you the support of installing gradle & reduce much time to installing & finding gradle version compability.
    
  2. Checking this info you can run java --version

    java version "1.8.0_321"
    Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
    Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
    
  3. After install JDK you will get a path in your machine like this C:\Program Files\Java or C:\Program Files (x86) you able to see this two folder path.

    jdk1.8.0_321
    jre1.8.0_321
    
  4. Update environment variable

    // Add these in User Variables :
    
    ANDROID_HOME : C:\Users\theanam\AppData\Local\Android\Sdk
    ANDROID_PLATFORM_TOOLS : C:\Users\theanam\AppData\Local\Android\Sdk\platform-tools
    ANDROID_TOOLS : C:\Users\theanam\AppData\Local\Android\Sdk\tools
    JAVA_HOME : C:\Program Files\Java\jdk1.8.0_321
    
    //Add these in System Variables path:
    
    C:\Program Files\Java\jre1.8.0_321\bin  // Otherwise you will get Jarsigner is not recognized internal or external command
    
    C:\Program Files\Java\jdk1.8.0_321\bin // Otherwise keytool is not recognized internal or external command
    
    C:\Program Files (x86)\Common Files\Oracle\Java\javapath
    C:\gradle-7.4.1\bin  // If path not found installed it.
    

Ionic App build stage & Signing unsigned apk

  1. Go to the App Folder
  2. Open terminal in that folder.
  3. Run keytool -genkey -v -keystore HERE_YOUR_KEY_NAME-key.keystore -alias HERE_YOUR_APP_ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000. You will find a keystore file is generated in your app folder.
  4. Run ionic cordova build android --prod --release --verbose
   After successfully executed this command you will get a message like this,
   Built the following apk(s):
       D:\xyz\ion-cordova\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk

   It generate an unsigned apk that you never install in a phone so need to sign this apk.
Enter fullscreen mode Exit fullscreen mode
  1. Run jarsigner --verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore HERE_YOUR_KEY_NAME-key.keystore "D:\xyz\ion-cordova\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk" HERE_YOUR_APP_ALIAS_NAME it will start signing this apk.

Now you are happy to go with the APP.

Signing Off
Sefat

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools πŸ”

Top comments (3)

Collapse
 
sefatanam profile image
Sefat Anam β€’ β€’ Edited

If you have already a keystore see the content inside it by

keytool -list -v -keystore my-release-key.keystore

then it will ask you to enter password.

Collapse
 
coderlifeisawesome profile image
lifeascoder β€’

Great job Man!!!

Collapse
 
sefatanam profile image
Sefat Anam β€’ β€’ Edited

Thanks @coderinfinity πŸ’–

Billboard image

πŸ“Š A side-by-side product comparison between Sentry and Crashlytics

A free guide pointing out the differences between Sentry and Crashlytics, that’s it. See which is best for your mobile crash reporting needs.

See Comparison

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay