Build a phonegap environment and use eclipse + phonegap

Source: Internet
Author: User
Today, I want to build a new phonegap environment, using eclipse + phonegap, using corvada1.7.0 and ADT 17. The first build based on android2.2 failed. It's strange that I don't know where the error occurred, it always fails to run normally. The official documents cannot be fully written. It's in a hurry. I just finished it. It may be because I didn't strictly follow the official requirements in the past. I had a problem with the sequence or something, and I did it again. Now I can. Next, we will try to build a phonegap environment with dreaweav: 1. Open eclipse and click New> Android project under the File menu.

 

Here, you can enter the packagename you want and click Finish. 2. Create two directories in the root directory of the project: /libs/assets/WWW copy the cordava-1.7.0.js from the phonegap just downloaded to the/assets/WWW directory copy the cordova-1.7.0.jar from the phonegap just downloaded to the/libs directory copy XML from the phonegap just downloaded folder to the/RES directory to make a small adjustment to the main java file in the SRC folder of Eclipse: (for example) change the class inheritance class from activity to droidgap and replace setcontentview () with super. loadurl ("file: // android_asset/www/index.html"); add import Org. apache. cordova. *; remove import android. app. activity; like the following:

 

 

3. Right-click androidmanifest. xml and choose open mode> text editor to copy the following permission settings to versionname: (for example) the red part needs to be added by yourself: <? XML version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. cordova. test "Android: versioncode =" 1 "Android: versionname =" 1.0 "> <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 =" androi D. 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-perm Ission 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_stor Age "/> <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 "/> <uses-SDK Android: minsdkversion =" 8 "/> <application Android: icon =" @ drawable/ic_launcher "Android: label = "@ string/app_name"> <activity Android: Name = ". testactivity "Android: Label =" @ St Ring/app_name "Android: configchanges =" orientation | keyboardhidden "> <intent-filter> <action Android: Name =" android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity> </Application> </manifest> 4. Write a helloworld file and test the file index.html In the"/assets/wwwsets "directory, and paste the following code: <! Doctype HTML>

Click "run". A dialog box is displayed:

The above part is to deploy the project to the actual mobile phone, you need to connect the mobile phone to the computer, and enable USB debugging, and the following box is deployed to the simulator, you need to create a new simulator here. If you do not have one, click manager to create a new simulator, select the simulator, and then click OK to deploy it to the simulator. Try:

 

 

Succeeded. Deploy to mobile phone:

 

 

 

 

After confirmation, the mobile phone is displayed as follows:

Again.
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.