eclipse / Android上的Cordova phonegap
Posted
技术标签:
【中文标题】eclipse / Android上的Cordova phonegap【英文标题】:Cordova phonegap on eclipse/ Android 【发布时间】:2012-06-11 12:52:35 【问题描述】:我正在尝试使用 Phonegap (cordova) 将 sencha touch 2.0 项目安装到 android 模拟器中。
我按照教程中提到的步骤尝试了 HelloWorld 示例,它可以工作!
我把我的项目放在assests文件夹下的www目录下,cordova jar文件,xml文件夹也加进去了
在主课中,我做了以下事情:
super.loadUrl("file:///android_asset/www/index.html");
但运行应用程序后,它会在控制台中显示以下内容:
[2012-06-11 15:48:27 - PhoneGap] Uploading PhoneGap.apk onto device 'emulator-5554'
[2012-06-11 15:36:13 - PhoneGap] Uploading PhoneGap.apk onto device 'emulator-5554'
[2012-06-11 15:38:10 - PhoneGap] Installing PhoneGap.apk...
[2012-06-11 15:38:12 - PhoneGap] Installation failed due to invalid APK file!
[2012-06-11 15:38:12 - PhoneGap] Please check logcat output for more details.
[2012-06-11 15:38:13 - PhoneGap] Launch canceled!
日志猫:
06-11 13:00:27.003: DEBUG/SntpClient(65): request time failed: java.net.SocketException: Address family not supported by protocol
06-11 13:04:24.309: DEBUG/dalvikvm(141): GC_EXPLICIT freed 1K, 12% free 14374K/16327K, paused 11ms+5ms
06-11 13:05:27.041: DEBUG/SntpClient(65): request time failed: java.net.SocketException: Address family not supported by protocol
06-11 13:06:05.003: INFO/installd(34): free_cache(6710880) avail 4059136
06-11 13:06:05.009: ERROR/installd(34): cannot open /data/secure/data/: No such file or directory
06-11 13:06:05.341: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.349: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.349: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.370: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.370: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.370: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.370: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.401: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.431: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.431: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.453: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.453: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.453: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.453: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.459: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.473: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.479: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.502: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.519: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.529: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.529: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.529: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.529: ERROR/installd(34): Couldn't openat cache: No such file or directory
06-11 13:06:05.539: WARN/PackageManager(65): Couldn't clear application caches
06-11 13:06:05.539: INFO/DeviceStorageMonitorService(65): Running low on memory. Sending notification
06-11 13:06:05.871: DEBUG/Tablet/NotificationPanel(266): notificationCount=1
06-11 13:06:06.123: INFO/dalvikvm(266): Jit: resizing JitTable from 512 to 1024
06-11 13:06:06.209: WARN/ActivityManager(65): Unable to start service Intent act=com.android.email.intent.action.MAIL_SERVICE_CANCEL cmp=com.android.email/.service.MailService : not found
06-11 13:06:12.769: DEBUG/dalvikvm(286): GC_EXPLICIT freed 67K, 9% free 6420K/6983K, paused 4ms+10ms
我是否必须更新我的 index.html 文件以包含 cordova.js 文件??
【问题讨论】:
Please check logcat output for more details.
见鬼...在 index.html 中包含 cordova.js 文件
我包含了,同样的问题
我需要做点别的吗(我是初学者)
【参考方案1】:
如果您使用 eclipse 创建原生 android 应用程序,那么在您的 android 模拟器中运行 sencha 应用程序真的很简单。
我可以告诉你一些简单的步骤。
1)我建议你使用MDS applaud phone gap http://wiki.phonegap.com/w/page/34483744/PhoneGap%20Eclipse%20PlugIn%20for%20Android来安装phonegap。
2) 完成安装后,您会在顶部看到电话间隙图标。
3)然后点击它来创建一个最小电话间隙项目。
4) 然后你会看到索引文件有不必要的东西。你可以替换索引文件如下
<!DOCTYPE html>
<html>
<head>
<title>The Sencha Touch List Component</title>
<link rel="stylesheet" href="app.css" type="text/css">
<script type="text/javascript" src="touch/sencha-touch-all.js"></script>
<script type="text/javascript" charset="utf-8">
Ext.Loader.setConfig(
enabled: true,
paths: 'Ext': 'touch/src'
);
</script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
5)如果你想使用电话间隙功能,你也可以包含 phonegap.js。然后在资产文件夹中,你可以创建创建 sencha 应用程序所需的文件夹。比如 app 文件夹,styles 文件夹,touch 文件夹以及其他必要的东西,如 css 文件和应用程序。位于 www 文件夹中。
6)你可以通过只在eclipse中查看web浏览器中的index.html文件来检查配置是否正确。
7) 如果没问题,那么你可以在你的安卓模拟器中运行应用程序,就像你为你的原生应用程序做的一样。
【讨论】:
以上是关于eclipse / Android上的Cordova phonegap的主要内容,如果未能解决你的问题,请参考以下文章
Eclipse 中 Android 平板电脑模拟器上的“未选择目标”错误
如何在 Eclipse 构建的 Android 应用程序中删除屏幕上的键