ITeye博客

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

maxer025 · 2017-08-24 15:43 · 移动开发 · Markdown

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> tittle window.location='./main.html';

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

找到项目中res/xml目录下的config.xml,把你的外网的域名地址添加到配置中

方法四: index.html 里面https引用copy到本地,直接从本地引用,不通过http

 <script  src="lib/angular-storage/dist/angular-storage.js"></script>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。