Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

4.4 How to Convert Angular project to Android APK in 10 steps.

 ads

How to Convert Angular project to Android APK in 10 steps.

ads

In this text you may learn how to convert your present Angular challenge into a hybrid app running on Android.

ads


Ifyou are a web developer Angular possibly crossed your path a couple of times. Angular (in addition to other javascript frameworks like react or vue.js) is a awesome cool frontend framework to construct small and easy as much as big and complicated internet applications.

ads


As a developer I usually try and offer the person the best feasible person enjoy. that when meant that I needed to broaden a telephone app in preference to a web software. As a javascript fanatic I didn’t need to begin developing in c, c++ or java. So I did a few research and quickly came to the conclusion that you may easily develop telephone apps with a javascript framework as a basis. constructing new hybrid apps from scratch is already quite precise documented however I also wanted to update existing web projects to be deployed as hybrid apps.

ads


After this educational you will be capable of construct your current Angular net mission as an android mobile app (APK), get it running in your android device and even deploy it to the play store (of path you can additionally create a new Angular assignment and setup the APK constructing manner). You must have a primary information approximately Angular improvement. there's no in addition information vital (Cordova, java, android studio, etc). Please understand that such things as step-by-step instructions in internet improvement are constantly pretty impossible. There are too many differences in each setups and initiatives to jot down a one-suits-all academic. If questions rise up — don’t hesitate to ask. despite the fact that, permit’s get started!

ads


Step 1

Setup Android Studio SDK


Step 2

install Cordova globally

ads


npm installation -g cordova

Step 3

I anticipate which you have an existing Angular project at hand. otherwise you may speedy create a check challenge with ng new hello-app-world (when you have in no way used Angular before, deploy Angular CLI). Navigate into the newly created project. Run ng serve for a dev server and open http://localhost:4200/.

ads


Step 4

Create a brand new Cordova undertaking


cordova create whats up-app-international-cordova com.example.hey OurFirstApp

Step 5

To develop Cordova packages, you have to install SDKs for each mobile platform you're focused on. Navigate into the newly created Cordova project and add Android as platform.

ads


cordova platform add android

Step 6

Now merge the just created Cordova task into our Angular assignment. copy each folder and record of the Cordova project assume the package.json, the package deal-lock.json and the node_modules folder into the Angular mission root. The folder shape of your Angular project have to now appearance some thing like this:


ads


Folder shape of the Angular task root

Step 7

Merge the Cordova bundle.json into the Angular package deal.json. You don’t want to duplicate the scripts item from the Cordova package.json. Overwrite the Angular package deal.json call with the Cordova bundle.json name. the entirety else ought to be easy mergeable. The resulting bundle.json on your Angular undertaking ought to now appearance something like this:

ads



shape of the Angular bundle.json

Step eight

Open the index.html of the Angular undertaking and change the base href from  to:


ads


Step 9

visit the tsconfig.json and make sure in compilerOptions the target is ready to es5! Angular variations ≥ eight can have bring together target set to es2015 (ES6) by way of default however Android Emulators do have issues with ES6. So set goal to es5 (ES5). if you don’t have your target set to es5 you will get a white display screen on your emulator.

ads


Step 10

On default Angular creates a /dist folder while building your venture at the same time as Cordova builds its APK into the /www folder. We want to have one unite target course. go to the angular.json and change the outputPath to “www”.

ads


Setup is now achieved. allow’s construct our Angular app after which wrap it with Cordova.


ng construct --prod --aot

cordova construct android

ads


Hurray! Now your APK is prepared for checking out on a digital Android device. Open Android Studio. Open the Android digital device manager. Create a new virtual tool (hardware and Android version as you like). start the tool. as soon as the virtual tool has booted, you may begin the debug APK for your virtual device with this command:

ads


cordova emulate android

ads


App going for walks on a digital Android tool

It’s that smooth. With these few steps you can convert your Angular venture as a hybrid app into an Android app for smartphones. *


*It’s additionally pretty clean with different systems like iOS.

ads


One small step is but to come back: Our debug APK presently only works on digital Android gadgets. to be able to be able to install the APK on real hardware Android gadgets or even make it to be had within the Play store we need to release and signal the app. An unsigned APK can't be set up on Android structures. however we are able to without problems signal our APK ourselves.

ads


First we need to launch the app:


cordova construct --launch android

this may create an unsigned model of your APK at platforms/android/app/construct/outputs/apk/launch. To self-sign our APK we want to generate a keystore:

ads


keytool -genkey -v -keystore helloappworld.keystore -alias helloappworldmobileapps -keyalg RSA -keysize 2048 -validity ten thousand

The keytool command will activate you with a password and different certificates fields. once you stuffed out the fields a keystore report may be generated. save your keystore very cautiously!

ads


Then we want to signal the java archive bundle:

ads


jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore helloappworld.keystore app-release-unsigned.apk helloappworldmobileapps

One final mandatory step in case you want to upload the APK to the Play shop (Zipalign is a device furnished with the aid of the Android SDK. when you have configured your $ANDROID_HOME var wrong, you could find zipalign with this command: discover ~/Library/Android/sdk/build-tools -call “zipalign”.):

ads


zipalign -v four app-launch-unsigned.apk app-launch-signed.apk

That’s it. Now you have got your release-ready and signed APK that you could install on your Android smartphone.

ads


you can develop and optimize your Android app. test out the Cordova doctors. you can set off many cool plugins and use features like push notifications, vibration remarks and splash screens or modify easy such things as coloration of the reputation bar.

ads


you could additionally observe the source code and config files of a demo venture for this educational proper here.

ads


replace January 2020: This tutorial nevertheless works with the ultra-modern versions of Angular and Cordova. My Angular model is eight.three.23 and my Cordova model is nine.0.zero. Have amusing.

ads


test out our other cool tasks at liechtenecker.at or the german version of this educational.

ads


i'm hoping I should provide you with an amazing guide. when you have tips for optimization, i am very happy about your remarks. If questions popped up, don’t be afraid to invite.

ads

Make the internet a higher area. 

ads

In this text you may learn how to convert your present Angular challenge into a hybrid app running on Android.

ads


Ifyou are a web developer Angular possibly crossed your path a couple of times. Angular (in addition to other javascript frameworks like react or vue.js) is a awesome cool frontend framework to construct small and easy as much as big and complicated internet applications.

ads


As a developer I usually try and offer the person the best feasible person enjoy. that when meant that I needed to broaden a telephone app in preference to a web software. As a javascript fanatic I didn’t need to begin developing in c, c++ or java. So I did a few research and quickly came to the conclusion that you may easily develop telephone apps with a javascript framework as a basis. constructing new hybrid apps from scratch is already quite precise documented however I also wanted to update existing web projects to be deployed as hybrid apps.

ads


After this educational you will be capable of construct your current Angular net mission as an android mobile app (APK), get it running in your android device and even deploy it to the play store (of path you can additionally create a new Angular assignment and setup the APK constructing manner). You must have a primary information approximately Angular improvement. there's no in addition information vital (Cordova, java, android studio, etc). Please understand that such things as step-by-step instructions in internet improvement are constantly pretty impossible. There are too many differences in each setups and initiatives to jot down a one-suits-all academic. If questions rise up — don’t hesitate to ask. despite the fact that, permit’s get started!

ads


Step 1

Setup Android Studio SDK


Step 2

install Cordova globally

ads


npm installation -g cordova

Step 3

I anticipate which you have an existing Angular project at hand. otherwise you may speedy create a check challenge with ng new hello-app-world (when you have in no way used Angular before, deploy Angular CLI). Navigate into the newly created project. Run ng serve for a dev server and open http://localhost:4200/.

ads


Step 4

Create a brand new Cordova undertaking


cordova create whats up-app-international-cordova com.example.hey OurFirstApp

Step 5

To develop Cordova packages, you have to install SDKs for each mobile platform you're focused on. Navigate into the newly created Cordova project and add Android as platform.

ads


cordova platform add android

Step 6

Now merge the just created Cordova task into our Angular assignment. copy each folder and record of the Cordova project assume the package.json, the package deal-lock.json and the node_modules folder into the Angular mission root. The folder shape of your Angular project have to now appearance some thing like this:


ads


Folder shape of the Angular task root

Step 7

Merge the Cordova bundle.json into the Angular package deal.json. You don’t want to duplicate the scripts item from the Cordova package.json. Overwrite the Angular package deal.json call with the Cordova bundle.json name. the entirety else ought to be easy mergeable. The resulting bundle.json on your Angular undertaking ought to now appearance something like this:

ads



shape of the Angular bundle.json

Step eight

Open the index.html of the Angular undertaking and change the base href from  to:


ads


Step 9

visit the tsconfig.json and make sure in compilerOptions the target is ready to es5! Angular variations ≥ eight can have bring together target set to es2015 (ES6) by way of default however Android Emulators do have issues with ES6. So set goal to es5 (ES5). if you don’t have your target set to es5 you will get a white display screen on your emulator.

ads


Step 10

On default Angular creates a /dist folder while building your venture at the same time as Cordova builds its APK into the /www folder. We want to have one unite target course. go to the angular.json and change the outputPath to “www”.

ads


Setup is now achieved. allow’s construct our Angular app after which wrap it with Cordova.


ng construct --prod --aot

cordova construct android

ads


Hurray! Now your APK is prepared for checking out on a digital Android device. Open Android Studio. Open the Android digital device manager. Create a new virtual tool (hardware and Android version as you like). start the tool. as soon as the virtual tool has booted, you may begin the debug APK for your virtual device with this command:

ads


cordova emulate android

ads


App going for walks on a digital Android tool

It’s that smooth. With these few steps you can convert your Angular venture as a hybrid app into an Android app for smartphones. *


*It’s additionally pretty clean with different systems like iOS.

ads


One small step is but to come back: Our debug APK presently only works on digital Android gadgets. to be able to be able to install the APK on real hardware Android gadgets or even make it to be had within the Play store we need to release and signal the app. An unsigned APK can't be set up on Android structures. however we are able to without problems signal our APK ourselves.

ads


First we need to launch the app:


cordova construct --launch android

this may create an unsigned model of your APK at platforms/android/app/construct/outputs/apk/launch. To self-sign our APK we want to generate a keystore:

ads


keytool -genkey -v -keystore helloappworld.keystore -alias helloappworldmobileapps -keyalg RSA -keysize 2048 -validity ten thousand

The keytool command will activate you with a password and different certificates fields. once you stuffed out the fields a keystore report may be generated. save your keystore very cautiously!

ads


Then we want to signal the java archive bundle:

ads


jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore helloappworld.keystore app-release-unsigned.apk helloappworldmobileapps

One final mandatory step in case you want to upload the APK to the Play shop (Zipalign is a device furnished with the aid of the Android SDK. when you have configured your $ANDROID_HOME var wrong, you could find zipalign with this command: discover ~/Library/Android/sdk/build-tools -call “zipalign”.):

ads


zipalign -v four app-launch-unsigned.apk app-launch-signed.apk

That’s it. Now you have got your release-ready and signed APK that you could install on your Android smartphone.

ads


you can develop and optimize your Android app. test out the Cordova doctors. you can set off many cool plugins and use features like push notifications, vibration remarks and splash screens or modify easy such things as coloration of the reputation bar.

ads


you could additionally observe the source code and config files of a demo venture for this educational proper here.

ads


replace January 2020: This tutorial nevertheless works with the ultra-modern versions of Angular and Cordova. My Angular model is eight.three.23 and my Cordova model is nine.0.zero. Have amusing.

ads


test out our other cool tasks at liechtenecker.at or the german version of this educational.

ads


i'm hoping I should provide you with an amazing guide. when you have tips for optimization, i am very happy about your remarks. If questions popped up, don’t be afraid to invite.

ads

Make the internet a higher area. 

ads



Post a Comment

0 Comments