在 Android 上运行 Sencha Touch / PhoneGap 示例代码时出现问题
大家好,我正在运行本教程:
http:// /www.sencha.com/learn/a-sencha-touch-mvc-application-with-phonegap
并尝试让代码在 Android 上运行。我设置了 Eclipse 并针对 Android 2.3.3
我已经从 Git 下载了最终代码,但我不断收到错误(在 LogCat 中):
02-01 14:59:08.709: E/Web Console(16659): Uncaught ReferenceError: device is not Define at file:///android_asset/www/app/app.js:8
有问题的代码是:
Ext.regApplication({
name: 'app',
launch: function() {
this.launched = true;
this.mainLaunch();
},
mainLaunch: function() {
if (!device || !this.launched) {return;}
this.views.viewport = new this.views.Viewport();
}
});
无论是在模拟器上运行还是在模拟器上运行,我都会遇到相同的错误物理设备。我已经设置了 Weinre,但它没有给我任何有用的信息,只是说明 “发生错误:[未知文件名]:[未知行号]:[未知消息]”
Hi guys I'm running through this tutorial:
http://www.sencha.com/learn/a-sencha-touch-mvc-application-with-phonegap
and trying to get the code running on Android. I'm set up with Eclipse and targeting Android 2.3.3
I've downloaded the final code from Git but I keep getting the error (in LogCat):
02-01 14:59:08.709: E/Web Console(16659): Uncaught ReferenceError: device is not defined at file:///android_asset/www/app/app.js:8
The code in question is:
Ext.regApplication({
name: 'app',
launch: function() {
this.launched = true;
this.mainLaunch();
},
mainLaunch: function() {
if (!device || !this.launched) {return;}
this.views.viewport = new this.views.Viewport();
}
});
I get the same error whether running on the emulator or a physical device. I've got Weinre set up but it didn't give me any useful information, only stating
"error occured: [unknown filename]:[unknown lineno]: [unknown message]"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我很确定“app”与 PhoneGap 中的 App 类冲突,可以通过 navigator.app 访问该类。尝试将名称更改为“myapp”,看看是否可以解决您的问题。
I'm pretty sure that "app" is conflicting with the App class in PhoneGap which is accessible at navigator.app. Try changing the name to "myapp" and see if it fixes your problem.
同样的事情也发生在我身上。将
添加到 AndroidManifest.xml 中,它就会消失。Same thing happened to me. Add
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
to AndroidManifest.xml and it should go away.我遇到了类似的问题,但只有在包含 JS 文件以使 weinre 工作时才会出现这种情况。如果您在我的设置中删除它,它会正常加载应用程序。不知道为什么,目前正在寻找修复它,因为当然需要我们帮助调试!
I am having a similar issue but it only occurs when including the JS file for weinre to work. If you remove that on my setup it loads the application fine. Not sure why and currently on the hunt to get it fixed as need weinre to help with debugging of course!