Site icon MAZ TECH

How to convert Angular project to Android app

Today we are going to talk about how to convert an angular project to an android app. Here we are going to use “Capacitor”. “Capacitor” is a cross-platform native runtime that makes it easy to build modern web apps that run natively on iOS, Android, and the Web. Angular is used to create single-page web applications. You can create responsive web applications using Angular and convert them into Android or IOS using Capacitor.

In this lessen we hope to talk only how to convert Angular project to Android app. So you have to download and install Android studio before try this.

First of all, we have to create an Angular project. If you are a beginner to Angular. See How to start an Angular project. Now you can see your project like below.

figure 01

Step 1: Install Capacitor in your project

After you created, go to the project location and open CMD from there. If you have an existing Angular project open the CMD inside the project folder. Now we are going to install “Capacitor”. Run the below code in the CMD.

npm install --save @capacitor/core @capacitor/cli

After successfully installed the capacitor you see in the pckage.json file like figure 02.

figure 02

Step 2: Change Output Path to “www”

Then open the “angular.json” file and change “outputPath”: “dist/AngularApp” to “outputPath”: “www”.


Step 3: Build Product

Then save the project and run the below code to build the product. That compiles the Angular app into an output directory.

ng build

Step 4: Initialise Capacitor in your project

npx cap init

Step 5: Add Android platform

npx cap add android

After that, If you change anything in the web-based code, you can use the below code to copy those things to the native app.

npx cap copy android

Then run the below code to open the application in Android Studio.

npx cap open android

After the run “npx cap open android“, android studio automatically open and then you can run the app on the emulator or your phone using USB debugging. Then you can see the output like below in your phone or emulator.


Update converted Android app

After you update your web application, you can run the below codes in CMD or code editor terminal.

ng b --prod
npx cap copy android
npx cap open android

I think now you have a clear idea about “How to convert Angular project to Android app”. If you have any problem about “convert Angular project to Android app” comment on it or contact us using messenger. Let’s meet in the next lesson. And you can follow our Web Design Tutorial HERE.

Happy Coding!

React JS user registration with PHP and MySQL

Exit mobile version