先工具准备:
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"
/>
完整代码是:
<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"
/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".App" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
之后 就是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 没复制进去
暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录