---
title: "Getting started with PhoneGap in Eclipse for Android"  
description: "In this article I am explaining how to started project with PhoneGap in Eclipse for Android"  
author: "Manoj Pandey"  
published: 2015-03-25  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1687/getting-started-with-phonegap-in-eclipse-for-android  
category: "phonegap"  
tags: ["phonegap"]  
reading_time: 3 minutes  

---

# Getting started with PhoneGap in Eclipse for Android

PhoneGap is an open source platform that allows you to create cross-platform [mobile applications](https://answers.mindstick.com/qa/114550/how-do-you-approach-compatibility-testing-for-mobile-applications) with HTML, JavaScript, and CSS. In order to interact with device hardware, PhoneGap provides a JavaScript API that will interface with features such as the on-board camera, GPS, and accelerometer. Even though PhoneGap is great for developing cross-platform applications, the code for developing applications while targetting one platform or another will vary. [One of the greatest](https://answers.mindstick.com/qa/31387/cyber-bullying-is-one-of-the-greatest-problems-in-the-world-today-how-would-you-solve-this) differences to overcome is the required [software requirements](https://www.mindstick.com/blog/245/software-requirements-and-guidelines-for-developing-android-application). This tutorial will provide an in-depth review of [setting up](https://www.mindstick.com/articles/13112/setting-up-the-perfect-configuration-for-your-work-computer) your [development environment](https://www.mindstick.com/interview/34043/setting-up-a-development-environment-in-knockout) for Android, and will build a simple "[Hello World](https://www.mindstick.com/forum/23190/why-does-this-code-using-random-strings-print-hello-world)" app.

You have need to follow some steps to use phone gap in eclipse

##### 1. Setting up Android Tools

ADT Bundle – Just a single step to setup [android development](https://www.mindstick.com/articles/12015/a-revolution-in-mobile-industry-magic-of-android-development) environment.

##### 2. Downloading and installing PhoneGap

##### \
· Visit the PhoneGap download page and click the orange Download link to begin

##### the download process.

##### · Extract the archive to your local file system for use later.

##### \
3. Creating the project in Eclipse

##### \
Follow these steps to create a new Android project in Eclipse:

##### Choose New > Android Project

##### \
4. After create your android application project you have need Configure the

##### project to use PhoneGap.

##### At this point, Eclipse has created an empty Android project. However, it has not yet

##### been configured to use PhoneGap. You’ll do that next.

##### \
Create an assets/www directory and a libs directory inside of the new Android

##### project. All of the HTML and JavaScript for your PhoneGap application interface will

##### reside within the assets/www folder

##### ![Getting started with PhoneGap in Eclipse for Android](https://www.mindstick.com/mindstickarticle/407170f2-5ce1-44de-a946-28d9cdd7c0fd/images/15fbf0cc-4fa6-4d3e-829f-d308cccd9317.png)

To copy the required files for PhoneGap into the project, first locate the directory where you downloaded PhoneGap, and navigate to the lib/android subdirectory.\
Add following file’s from phonegap android directorty

· Copy cordova-2.7.0.js to the assets/www directory within your Android project.

· Copy cordova-2.7.0.jar to the libs directory within your Android project.

· Copy the xml directory into the res directory within your Android project

\
![Getting started with PhoneGap in Eclipse for Android](https://www.mindstick.com/mindstickarticle/407170f2-5ce1-44de-a946-28d9cdd7c0fd/images/b62c193f-c40a-4059-b999-2f845898a0dd.png)

\
**5.** Add following permission in Manifest file

```
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.myapp"    android:versionCode="1"    android:versionName="1.0" >     <supports-screens        android:anyDensity="true"        android:largeScreens="true"        android:normalScreens="true"        android:resizeable="true"        android:smallScreens="true" />     <uses-sdk        android:minSdkVersion="8"        android:targetSdkVersion="18" />     <uses-permission android:name="android.permission.INTERNET" />    <uses-permission android:name="android.permission.CAMERA" />    <uses-permission android:name="android.permission.VIBRATE" />    <uses-permission android:name="android.permission. ACCESS_COARSE_LOCATION" />    <uses-permission android:name="android.permission. ACCESS_FINE_LOCATION" />    <uses-permission android:name="android.permission. ACCESS_LOCATION_EXTRA_COMMANDS" />    <uses-permission android:name="android.permission.INTERNET" />    <uses-permission android:name="android.permission.RECEIVE_SMS" />    <uses-permission android:name="android.permission.RECORD_AUDIO" />    <uses-permission android:name="android.permission.RECORD_VIDEO" />    <uses-permission android:name="android.permission. MODIFY_AUDIO_SETTINGS" />    <uses-permission android:name="android.permission.READ_CONTACTS" />    <uses-permission android:name="android.permission.WRITE_CONTACTS" />    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    <uses-permission android:name="android.permission.GET_ACCOUNTS" /><uses-permission android:name="android.permission.BROADCAST_STICKY" />     <application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme" >        <activity            android:name="com.example.myapp.MainActivity"            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"            android:label="@string/app_name" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />            <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application> </manifest>
```

**6.** Add following tag in index.html

```
<!DOCTYPE html><html><head> <title>Demo</title></head><body><h1>Hello PhoneGap</h1></body></html>
```

7. Add following code in MainActivity.class

```
package com.example.myapp; import android.os.Bundle;import android.widget.Toast; import org.apache.cordova.*; public class MainActivity extends DroidGap {                 @Override                public void onCreate(Bundle savedInstanceState) {                                try {                                                super.onCreate(savedInstanceState);                                                 super.loadUrl("file:///android_asset/www/index.html");                                } catch (Exception ex) {                                 }                } }
```

##### Now run your application

![Getting started with PhoneGap in Eclipse for Android](https://www.mindstick.com/mindstickarticle/407170f2-5ce1-44de-a946-28d9cdd7c0fd/images/1208afa6-1c85-43d1-a371-70d8e21f3f1b.png)

---

Original Source: https://www.mindstick.com/articles/1687/getting-started-with-phonegap-in-eclipse-for-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
