先工具准备:
1:Eclipse 下载地址:http://www.eclipse.org/downloads/
2:Android SDK Android SDK http://developer.android.com/sdk/index.html
3:ADT Plugin http://developer.android.com/sdk/eclipse-adt.html#installing
4:PhoneGap http://www.phonegap.com/
配置新的项目
打开 Eclipse,在文件菜单下面点击 New > Android Project
- 在项目的根目录, 创建两个目录:
- /libs
- /assets/www
- 从刚才下载的PhoneGap中复制phonegap.js 到/assets/www目录
- 从刚才下载的PhoneGap中复制phonegap.jar 到/libs目录
- 从刚才下载的PhoneGap中复制xml文到夹到/res 目录
- M对Eclipse的src文件夹中的主Java文件进行少量调整:(如下图)
- 将class的继承类由 Activity改为DroidGap
- 将setContentView() 这一行替换为 super.loadUrl(“file:///android_asset/www/index.html”);
- 添加import com.phonegap.*;
- 移除 import android.app.Activity;
2:右键单击AndroidManifest.xml并选择Open With > XMlEditor。加入一下
<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" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
完整代码是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.phonegap.helloworld"
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="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" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-sdk android:minSdkVersion="8" />
<application android:icon="[[[[[[[[[[[[[@drawable](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)](/user/drawable)/ic_launcher" android:label="[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[@string](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)/app_name"
android:debuggable="true">
<activity android:name=".App" android:label="[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[@string](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)/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>
<activity android:name="com.phonegap.DroidGap" android:label="[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[@string](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)](/user/string)/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
之后 就是index.html
随便写点就行了。
-
5A. 部署到模拟器
- 右键单击项目节点选择Run As 然后点击 Android Application
- Eclipse将要求你选择一个合适的AVD,如果没有设置的话,你需要创建一个AVD。
-
5B. 部署到设备
- 确认设备已经勾选USB debugging选项,并已将设备连接到电脑。(设置 > 应用程序 > 开发)
- 右键单击项目节点选择 Run As然后点击Android Application
爱看英文的去看英文教程:http://www.phonegap.com/start#android - 爱看图解释的 去看:http://phonegapcn.com/developers/get-started
到此为止,我手机有自己编写的HelloWorld 了
我遇到的问题是 我少了一步 总是进程stop 那就是 xml 没复制进去