Build and configure phonegap In the android Development Environment

Source: Internet
Author: User

After two days, the android development environment has been basically set up and phonegap has been configured. After referring to a lot of materials, I feel that I cannot rely on other people's materials, so I have to learn to make changes. The android development environment can be explained in a few words, but the actual operation is the most troublesome. The trouble is the download of various tools. I downloaded many versions and tried them many times. I forgot which version was last installed. How can I find out how to download it. The following are my steps for reference.

1. Download and build an environment tool

1. JDK(This is faster. Install it step by step)

To develop Android, you must set up a Java environment. Otherwise, the android SDK cannot be installed normally.

Check for successful installation: Start the DOS window and run cmd. In the DOS window, type Java-version. if the version information is displayed, the installation is normal. 2. Android SDK (The Official website seems to be blocked by ZF, so I am wondering) install it on the following page step by step (if it is a green version, double-click SDK manager ), Select the toos and Android version components to be downloaded (we recommend that you download the highest version, and download the latest version later). This step takes a long time. If the component is not easy to download, You can manually download the component from the Internet and put it in the platforms file in the Android-SDK file. if the version is compressed, You need to decompress the package.The temp file does not need to be compressed. Refer to my previous articleArticle: Http://www.cnblogs.com/duanhuajian/archive/2012/10/21/2732883.html

  3, Eclipse (This looks like a green software. After installation Program Eclipse will not appear)

Java development tools, classic version is recommended. Install After eclipse, select:

All references are as follows: in the pop-up dialog box, select the Add button and add https://dl-ssl.google.com/android/eclipse/. if you cannot download it, change httpsto http. The purpose of this step is to download the ADT plug-in. I have tried it many times but cannot download it. Search for the ADT plug-in on the Internet and download it to your local computer. Then, click archive... to find the ADT plug-in.

Click OK, and then click Next.

After the component is downloaded, the eclipse software is automatically restarted. The two buttons are added in the toolbar. You can use these two tools to download the latest components and create a new simulator.

2. After setting up the android environment, configure phonegap and create an android project:

1,New → project → Android Application project, click Next, and enter the basic information of the project.

2,After the project is created, create the → WWW folder in the assets file directory. Download phonegap and decompress it.

(1) copy the cordova-2.2.0rc1.js under the phonegap -- lib -- Android directory (the downloaded phonegap version prevails) file to the created WWW directory.

(2)Copy the cordova-2.2.0rc1.jar file to the libs folder.

(3)Copy the XML folder in phonegap to the res folder in the project directory.

3,Create the index.html file under/assets/wwwandLink to the phonegap JS file, as shown in figure:

 <!  Doctype html  >  <  Html  > <  Head  >  <  Meta  Charset  = "UTF-8"  >  <  Title  > </  Title  >  <  Script  Type  = "Text/JavaScript" Charset  = "UTF-8"  SRC  = "Cordova-2.2.0rc1.js"  > </  Script  >  </  Head  >  <  Body  >      <  H1  > I crossed the wall. </ H1  >  </  Body  >  </  Html  > 

4,Modify the XXX. Java file in the SRC folder as follows (this is not necessarily accurate. If there is an error, click the Red Cross on the left):

1 ) Modify the class inheritance and change the activity to droidgap. 2 ) Replace the setcontentview () line with super. loadurl ("file: // android_asset/www/index.html"); 3) You may need to add import org. Apache. Cordova. droidgap; Let's look at my example:

 

 

 

 

 

 

 

5,Right-click the androidmanifest. xml file in the project root directory and choose open with> Text Editor (open mode> text editor ),

The modified content is as follows:

 <  Manifest  Xmlns: Android  = "Http://schemas.android.com/apk/res/android"  Package  = "Com. example. Fruit"  Android: versioncode  = "1" Android: versionname  = "1.0"   >  /* Copy the following permission settings to start {*/     <  Supports-screens  Android: largescreens  = "True"  Android: normalscreens  = "True"  Android: smallscreens  = "True"  Android: resizeable  = "True"  Android: anydensity = "True"   />   <  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. read_phone_state"   />   <  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. 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"   />   /*} End */ 
< Uses-SDK Android: minsdkversion = "10" Android: targetsdkversion = "15" /> < Application Android: icon = "@ Drawable/ic_launcher" Android: Label = "@ String/app_name" Android: Theme = "@ Style/apptheme" > < Activity Android: Name = ". Mainactivity" Android: configchanges = "Orientation | keyboardhidden"// The content of this row is newly added Android: Label = "@ String/title_activity_main" > < Intent-Filter > < Action Android: Name = "Android. Intent. Action. Main" /> < Category Android: Name = "Android. Intent. Category. launcher" /> </ Intent-Filter > </ Activity > </ Application > </ Manifest >

6,Run

    • Right-click a project node and selectRunAnd then clickAndroid Application.
    • Eclipse requires you to select an appropriate AVD. If not set, you need to create an AVD.

7,Deploy to Device

    • Make sure that the USB debugging option is selected and the device is connected to the computer. (Settings> Applications> Development)
    • Right-click a project node and selectRun, ClickAndroid Application.

 

At this point, a project has been created. Each person may have different situations. Therefore, do not stick to this issue during installation. Please refer to other materials.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.