如何使用Ripple Emulator for Windows来测试PhoneGap应用程序? [英] How to use Ripple Emulator for Windows to test PhoneGap application?

查看:150
本文介绍了如何使用Ripple Emulator for Windows来测试PhoneGap应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用Ripple模拟器在Windows下测试PhoneGap应用程式吗?





我已经从Chrome商店安装了Chrome的Ripple Emulator扩展程序。我将Chrome导航到我的移动应用(通过XAMPP在本地投放)。我点击了Chrome浏览器旁边的Ripple图标,然后在打开的窗口中点击了启用。我选择了合适的平台( Cordova 2.0 )。



我的应用程序以类似移动的方式重新加载移动设备。 Ripple无法从 config.xml 文件中读取我的配置,但这是一个众所周知的错误(报告此处此处)。



我选择了我的设备( Samsung Nexus ),开始测试我的移动设备。甚至第一次调用PhoneGap API失败。我尝试了罗盘,但是我得到的是不能调用未定义的方法'watchHeading'。



如何基本PhoneGap对象未定义?我缺少什么?我可以使用Ripple模拟器在Chrome下在Windows下测试PhoneGap应用程序,或者我缺少了Ripple的整个构思?



我试图帮助自己使用Ripple文档, 启用Ripple仿真器是一个完全的垃圾。我在Ripple图标中只有启动Ripple服务选项的符号(只有启用禁用),当我单击启用时,没有许可协议的标志,我可以查看和接受。



如何使用Ripple在Chrome中测试PhoneGap应用程序? tl; dr:反之亦然。 对于PGB文档中的内容,您必须在应用程序的根目录中保留 cordova.js 文件的副本,并且该文件必须从正确版本2.0的PhoneGap,因为最新版本的Ripple仿真器不能与其他版本也不能与此文件不工作。



解决方案



我正在使用PhoneGap Build开发我的PhoneGap应用,而不是本地PhoneGap环境。所以 - 根据我的指示 - 我已经从我的应用程序的webroot中删除了 phonegap.js 文件,只剩下参考它 index.html 。这对于PhoneGap Build是好的,但是对于Ripple Emulator绝对



自从我把这个文件放回来后c> cordova.js 来自 lib\android\example\assets\www\ 文件夹从 phonegap -2.0.0.zip 我设法看到许可证,启动Ripple服务和测试当地工作PhoneGap应用程序。



问题:当前版本的Ripple Emulator使用 Cordova 2.0 。请确保您下载了PhoneGap的正确版本,并使用 cordova不要尝试使用 cordova.js 从新版本(目前 3.0.0 ),因为您可能遇到无法检测的情况,包括看到许多奇怪的 alert(),甚至挂起超载的Chrome。





一步一步

使用Chrome和Ripple Emulator在Windows下测试PhoneGap应用程序的关键步骤:


  1. cordova.js 文件还原到您的文件夹根目录并检查其引用。您可以从任何可下载版本的PhoneGap中的 lib\android\example\assets\\\\\\\\\\\\\\\\ c $ c>文件夹中获取它(您应该使用


  2. 安装 Ripple Emulator Chrome浏览器的扩展程序。


  3. 启动本地网络服务器并通过它运行您的移动应用程序的HTML代码(通过直接文件访问进行测试主要可能在Ripple仿真器中进行,


  4. 点击Ripple Emulator图标,直到您的Chrome浏览器,然后点击启用


  5. 接受许可协议并选择合适的平台(再次点击Ripple Emulator图标,然后点击启动Ripple服务

    / $>
  6. 设置目标平台(设备),并享受本地PhoneGap应用程序。




版本和API的差异



您还必须注意< a href =http://docs.phonegap.com/en/ =nofollow> PhoneGap API ,仔细检查,可用的内容以及它在PhoneGap 2.0.0中是如何访问的?例如,自那以后简单的连接类型检查已经改变。在 2.9.0 API 中,通过 navigator.connection ,而在 navigator.network 界面下访问 p>因为Ripple仿真器使用PhoneGap 2.0.0,目前支持的调用此对象的方法:

  var networkState = navigator.connection。类型; 

将失败。您必须以这种方式使用它:

  var networkState = navigator.network.connection.type; 

虽然您可以选择PhoneGap版本,但在PhoneGap Build中编译时(您可以强制使用版本2.0.0,尽管以不变的方式编译此代码),您将大多数likey想使用最新版本的PhoneGap开发您的应用程序。



在这种情况下,使用安全方法,这将工作在Ripple和PhoneGap:

  var networkState =((navigator.connection) ?navigator.connection.type:((navigator.network& navigator.network.connection)?navigator.network.connection.type:'unknown')); 

或者您可以声明一些特殊变量:

  var debugMode = typeof(window.tinyHippos)!=='undefined'; 

并将其用作开关:

  var networkState =(debugMode)? navigator.network.connection.type:navigator.connection.type; 

希望Ripple将很快更新到最新的PhoneGap,所以我们可以删除


Can Ripple emulator be used to test PhoneGap application under Windows?

Either I'm doing something really bad or Ripple is not working at all in such environment.

I have installed Ripple Emulator extension for Chrome from Chrome Store. I navigated Chrome to my mobile app (served locally via XAMPP). I clicked Ripple icon next to Chrome omnibar and clicked Enable in opened window. I've selected proper platform (Cordova 2.0).

My application was reloaded in mobile-like look, simulating mobile device. Ripple was unable to read my configuration from config.xml file, but that is a well known bug (reported here and here). I hope, this is not an issue that prevents me from using Ripple at all?

I've selected my device (Samsung Nexus) and begin to test my mobile device. Even first call to PhoneGap API has failed. I tried compass, but all I got was Cannot call method 'watchHeading' of undefined.

How can basic PhoneGap object be undefined? What am I missing? Can I test PhoneGap application under Windows in Chrome with Ripple Emulator or amy I missing the entire idea for what Ripple is?

I tried to help myself with Ripple documentation, but chapter "Enable the Ripple emulator" is a complete garbage. I don't have even a sign of Start Ripple Services option in Ripple icon (only Enable and Disable) and when I click Enable there is no sign of the license agreement, that I could review and accept. I'm getting the feeling that this doc talks about something completely different than I use.

How to use Ripple in Chrome to test PhoneGap application? What am I missing?

解决方案

tl;dr: On contrary to what is said in PGB's docs, you must keep a copy of cordova.js file in your app's root directory and this file must be taken from exactly version 2.0 of PhoneGap, as latest version of Ripple Emulator does not work neither with other version nor without this file.

Solution

I'm developing my PhoneGap apps using PhoneGap Build, not local PhoneGap environment. So -- as I was instructed -- I have deleted phonegap.js file from my application's webroot and only left reference to it in index.html. This is fine for PhoneGap Build, but absolutely not fine for Ripple Emulator.

Ever since I put that file back (actually cordova.js from lib\android\example\assets\www\ folder from phonegap-2.0.0.zip I managed to see license, start Ripple Services and test working PhoneGap application locally.

Notice for people struggling with similar problem: Current version of Ripple Emulator uses Cordova 2.0. Make sure, that you download right version of PhoneGap and take cordova.js from it! Do not attempt to use cordova.js from newer version (currently 3.0.0) as you may run into undetectable situations, including seeing many strange alert()'s and even hanging up overloaded Chrome.

Always make sure, that you're using PhoneGap's JS file version, that maches the one behind Ripple.

Step by step

Key steps to be able to test PhoneGap application under Windows, using Chrome and Ripple Emulator:

  1. Put cordova.js file back to your folder root and check the reference to it. You can grab it from lib\android\example\assets\www\ folder from any downloadable version of PhoneGap (you should use phonegap-2.0.0.zip though, see above).

  2. Install Ripple Emulator extension for your Chrome browser, using Chrome Store. Enable it.

  3. Start your local webserver and run your HTML code of your mobile application through it (testing through direct file access is mainly possible in Ripple Emulator, but highly not advisable and may produce unpredictable results).

  4. Click Ripple Emulator icon, right to your Chrome omnibar and then click Enable (or select proper option from context menu, right-clicking page).

  5. Accept license agreement and select proper platform (Cordova 2.0.0).

  6. Click Ripple Emulator icon again and click Start Ripple Services if they're not started automatically.

  7. Set destination platform (device) and enjoy working PhoneGap application locally.

Version and API differences

You also have to keep your eye for PhoneGap API and carefully check, what was available and how it was accessible in PhoneGap 2.0.0? For example, simple connection type checking has changed ever since that. In 2.9.0 API it is done via navigator.connection, while in 2.0.0 API it was accessed under the navigator.network interface.

Since Ripple Emulator uses PhoneGap 2.0.0, currently supported way of calling this object:

var networkState = navigator.connection.type;

will fail. You'll have to use it this way:

var networkState = navigator.network.connection.type;

Though you can select PhoneGap version, when compiling in PhoneGap Build (and you can force it to use version 2.0.0, though compile this code in an unchanged way), you will most likey want to develop your application using newest version of PhoneGap.

In this case, you have to use a "secured" approach, that will work in both Ripple and PhoneGap:

var networkState = ((navigator.connection) ? navigator.connection.type : ((navigator.network && navigator.network.connection) ? navigator.network.connection.type : 'unknown'));

Or you can declare some special variable:

var debugMode = typeof(window.tinyHippos) !== 'undefined';

And use it as a switch:

var networkState = (debugMode) ? navigator.network.connection.type : navigator.connection.type;

Hopefully, Ripple will be updated soon to newest PhoneGap so we could drop such things away.

这篇关于如何使用Ripple Emulator for Windows来测试PhoneGap应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆