Create a simple Android Application
The following tutorial we are learn about how to create a simple android application using cordova, we already learn about cordova installation and configuration.
After the cordova installation and cofiguration, open command prompt (windows key + R => type cmd=>press Enter)
Step 1:
First you need to choose the folder, create your folder on any of your drive, I have created the folder name "Android Cordova Project" in E:\ drive. Open command prompt and type your drive letter like E: and press enter. Next type cd E:\Android Cordova Project and press enter. Now your command prompt will see like below image.
Step 2:
That all now you have successfully ready to create the android project.
Step 3:
You need to create the folder name, package name and project name.
Syntax
Folder Name - One folder create in the current directory by this name.
Package Name -Your package name should start with com
Project name - Name of your android application
Example
Syntax
Example
Step 7:
After the cordova installation and cofiguration, open command prompt (windows key + R => type cmd=>press Enter)
First you need to choose the folder, create your folder on any of your drive, I have created the folder name "Android Cordova Project" in E:\ drive. Open command prompt and type your drive letter like E: and press enter. Next type cd E:\Android Cordova Project and press enter. Now your command prompt will see like below image.
That all now you have successfully ready to create the android project.
Step 3:
You need to create the folder name, package name and project name.
Syntax
cordova create FolderName PackageName projectname
Folder Name - One folder create in the current directory by this name.
Package Name -Your package name should start with com
Project name - Name of your android application
Example
cordova create TestApp com.Test.android "Test Application"
If you enter the above command and enter a new folder will created, this is the project folder.
Step 4:
Move to the newly created folder by using CD command (cd TestApp).
Step 5:
Lets add the platform, you can add windows, wp8, IOS, amazon-fireos, blackberry10, firefoxos. But now we are leaning the part of android os, so we will add the android os by the following command.
Syntax
cordova platform add android[@version]
@version - is optional
cordova platform add android@4.1.1
Step 6:
Go to the www folder and you can see some files including index.html. Now just we are modifying the index.html file.
Right click on the index.html file and open with notepad or any other editor and copy and paste the following code and save the file.
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body bgcolor="red">
This is the test android application
<script type="text/javascript" src="cordova.js"></script>
</body>
</html>
We did the coding side now we need to build the application and run, type the following command.
cordova build android
Wait few seconds, now this program was compiled and create a android-debug.apk file in "E:\Android Cordova Project\TestApp\platforms\android\build\outputs\apk".
Step 8:
Install the file in any android device and see the output. I am using bluestacks to view the output.
Open it and see the output.
Post a Comment for "Create a simple Android Application"