Application Error - The connection to the server was unsuccessful. (file:///and

Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)

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

问题分析:
这个应该是PhoneGap某些版本的BUG,尤其在index.html加载的内容较多时容易出现。

解决方法:
方法1:更新到PhoneGap的最新版本;
方法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 -->

方法四:
index.html 里面https引用copy到本地,直接从本地引用,不通过http
<!--script src="https://cdn.rawgit.com/auth0/angular-storage/master/dist/angular-storage.js"></script-->

<script src="lib/angular-storage/dist/angular-storage.js"></script>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值