Updated for Ionic 3.9.2
Just updated on 11/28/2017 – This was mostly just updating NPM packages but the main thing was to add the vendor.js file to the index.html
Updated for Ionic 3.7.1
Just updated on 10/20/2017 – There were a few things that needed to be done to the solution instead of just updating the NPM packages.
First update the index.html with:
<!– all code from node_modules directory is here –>
Then added the bolded text to the service-worker.js
self.toolbox.precache( [ './build/main.js', './build/vendor.js', './build/main.css', './build/polyfills.js', 'index.html', 'manifest.json' ] );
What did I learn today
Today I spent several hours setting up a default Ionic 3 project on my local machine and spent several more hours setting up Ionic Package to upload and build my Android application. While the instructions were not easy, I spent a lot of time looking at various different resources. This post will compile this list of resources and list the steps I used to get a very basic project up and running. This is my attempt to create a Visual Studio Starter Kit using Ionic 3 and Ionic Package
This is a list of all the things I read as well as downloaded to get my default project up and running.
- Ionic Package – http://docs.ionic.io/services/package/ – this is a deployment service for easy creation of native packages.
- Required Downloads
- Java JDK – Link – Accept License Agreement and Download/Install the version that fits your OS
- Cordova Tools for Visual Studio 2017
- Open Visual Studio 2017 Installer
- Click Modify
- LTS Node Version – Link
- NPM Task Runner – Link
- GitHub Visual Studio Extension – Link
Ionic Package Account
This set of instructions will setup your Ionic Apps account so that you can make use of Ionic’s Cloud Platform. Ionic has a free platform that is very generous and most personal projects would easily fit within those constraints. The paid accounts are also generally very inexpensive and make it very feasible for organizations to make use of. (I am not employed or sponsored by Ionic.) Details can be found here and pricing.
- Create a new account – https://apps.ionic.io/login
- Name Your First App – *Enter your project name here*
- Click Settings
- Click Certificates
- New Security Profile
- Name it *Enter your project name here*
Create KeyStore Security Credentials for Ionic Package Account
These are the Android instructions creating a keystore that is needed to package Ionic Android applications on Ionic Cloud.
- Open command prompt as administrator
- Copy/Paste the following:
- C:\Program Files\Java\jdk1.8.0_131\bin – This may be different depending on where you installed the JDK.
- Copy/Paste the following; Replace MY-RELEASE-KEY with your project name. Replace MY_ALIAS_NAME with your project name.
- keytool -genkey -v -keystore MY-RELEASE-KEY.keystore -alias MY_ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000
- Follow the Prompts
Creating Ionic Package Security Credentials
These steps will assign the newly created keystore to the security credentials in Ionic Package.
- Upload newly created keystore file, should be in C:\Program Files\Java\jdk1.8.0_131\bin or the directory your java jdk is installed.
- Type in key alias – Should be same as keystore name
- Type Passwords for Both
Deploying the Starter Kit
- Open Visual Studio
- Open Team Explorer
- In Local Git Repositories
- File -> Close Folder
- Open Solution “Mine is found in C:\Users\brett\Source\Repos\IonicLabOne as an example
- Open package.json – AND WAIT
- Build and cross your fingers.
- Open ionic.config.json
- Update “app_id” with id from apps.ionic.io
- You can find the app_id on apps.ionic.io – just replace the XXXXXX
- Open node command prompt
- Navigate to where you application is located (mine: C:\Users\brett\Source\Repos\IonicLabOne\IonicLabOne)
- Type the following
- Ionic login
- Type your credentials
- Type the following
- ionic package build android –profile *The name of the security profile you created*
- Download the package and send the .apk file to email address your phone has access to.
- Install app and open
I spent around five hours fuddling with all of these features and I wanted to create an easy starter kit that would let me get this setup rather quickly. This is the result of that work. I don’t know why it is so hard to get ionic templates setup for visual studio but hopefully this gets us closer to that day.