`

phonegap+jQuery mobile开发中碰到的问题集锦

 
阅读更多
第一个问题:

问题描述:

PhoneGap+Sencha Touch开发的应用,打包后的APP或者调试期间,在启动的时候提示如下信息:
Application Error - The connection to the server was unsuccessful.
(file:///android_asset/www/index.html)


问题分析:
1,这个应该是PhoneGap某些版本的BUG,尤其在index.html加载的内容较多时容易出现。
2,采用了alert()进行调试,中断了后续代码的运行。

解决方法:
方法1:更新到PhoneGap的最新版本;不要使用alert()调试;
方法2:设置加载超时属性
super.setIntegerProperty("loadUrlTimeoutValue",10000); 
完整代码如下(设置超时为 10 秒)

@Override
publicvoid onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/home/index.html");
    super.setIntegerProperty("loadUrlTimeoutValue",10000);

方法3:改名法
把index.html更名为main.html,然后新建一个index.html页面,内容如下:
<!doctype html> <html> <head> <title>tittle</title> <script> window.location='./main.html'; </script> <body> </body> </html>

主要原理就是通过一个过渡页面,把加载首页的内容最小化。

找到项目中res/xml目录下的config.xml,把你的外网的域名地址添加到配置中
<access origin="http://example.com" /> <!--allow any secure requests to example.com -->

第二个问题:

问题描述:

使用chrome调试时出现XMLHttpRequest cannot load http://54.214.8.118:8080/common/sendSidAction.action. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
这是因为Chrome默认不允许本地调用ajax请求,但手机上运行却没问题。

解决方案:

在Chrome的启动参数中添加如下

--allow-file-access-from-files

也就是在Chrome 的快捷方式->右键属性->目标框
里面,前边是Chrome运行程序的路径,后面 空格 --allow-file-access-from-files
即可

第三个问题:

关于Google地图API密匙的问题,进入地图的时候提示我“google已禁止对此应用使用地图API。.....”



google 网在中国内是禁用的。用电脑上google还是个问题啊 亲 ,手机不用说啦。

其他问题补充中...
  • 大小: 91.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics