Android Cordova项目报Applcation error the connection to the server was unsuccessful解决方法

Cordova Android Applcation error the connection to the server was unsuccessful.(file://androi_assets/www/index.html)

核心原因:

手机没有及时完成资源文件的加载。

可能导致的原因:

1.代码、数据、图片太大

2.脚本可能有无限循环或较长循环,因此加载时间太长。

3.使用过多的插件、脚本

结合本项目中的情况,排查,发现

1.使用本地的视频播放,视频达70m

修复方法:

放在视频放在服务端,将播放源设置为远程地址而不是本地

2.使用的切图打包到www/static下的图片资源较大,甚至有一个切图达800多k

修复方法:

优化UI资源,可删除的删除,不可删除的对切图进行压缩

3.index.html加载外部的css样式

修复方法:

将外部的css样式下载到本地,项目启动时加载本地css样式

配合代码:

1.延长超时时间

<preference name="loadUrlTimeoutValue" value="700000" />

2.加一个过渡页面

2.1新建mian.html,然后将index.html内容剪切到main.html,在index.html中加载main.html

 <script type="text/javascript">

window.location="./main.html";

  </script>

 

 

 

 

 

 

相关文章:

  • 2021-09-18
  • 2021-08-22
  • 2021-09-10
  • 2021-07-09
  • 2021-08-11
  • 2021-09-26
猜你喜欢
  • 2021-09-10
  • 2019-10-29
  • 2021-09-15
  • 2021-09-08
  • 2021-09-12
相关资源
相似解决方案