PhoneGap 常见错误集锦及解决办法

来源:互联网 发布:中国的软件行业 编辑:程序博客网 时间:2024/04/30 10:35

一:android app 启动错误,即出现:Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
分析:是PhoneGap某些版本的BUG,尤其在index.html加载的内容较多的时候容易出现,反正我是遇到过好多次

解决办法:(2,3都验证过,有效)

方法1:更新到PhoneGap的最新版本;

方法2:设置加载超时属性

super.setIntegerProperty("loadUrlTimeoutValue",10000);

完整代码如下:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/home/index.html");
    super.setIntegerProperty("loadUrlTimeoutValue", 10000);
方法3:过渡法:

将indext.html更名为main.html,然后新建一个index.html页面,内容如下:

<!doctype html> <html> <head> <title>tittle</title> <script> window.location='./main.html'; </script> <body> </body> </html>

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

 

二:PhoneGap Android Error initializing Cordova:Class not found
分析:环境配置有问题

解决办法(试验有效):

将安装包中的xml/config.xml拷到项目中res/xml下面(没有xml文件夹则创建一个)

 

待续...

原创粉丝点击