Application Error - The connection to the server was unsuccessful.
2018-03-07 18:03
423 查看
问题:
Application Error - The connection to the server was unsuccessful.(file://android-asset/www/index.html)
解决:
参考原网址: http://blog.csdn.net/qq_20473985/article/details/68490438 http://blog.csdn.net/zhanqizi/article/details/41349959
正文:
最近用phonegap封装前端页面做的项目时,遇到一个问题,分享一下,希望可以帮到有同样问题的朋友。
在启动应用时会报错:
Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
导致这个错误的原因是:在安卓load页面时,页面需要加载的内容没有加载完。
所以需要增加超时时间,或加一个过渡页来避免这个问题。
方案如下:
1.在load页面时,先load一个空的页面,当页面load完成时,再加载现在的index.html,
步骤如下: 1)将你的"index.html"改名为"main.html";
2)创建一个新的"index.html",把下面的内容放到"index.html"中, <script type="text/javascript"> window.location="./main.html"; </script>.2.将LoadUrlTimeoutValue设置为50或60秒,默认是20秒(此方案只能减少这个错误,无法从源头解决问题),
在config.xml中增加下面这行:<preference name="loadUrlTimeoutValue" value="50000" />
注:第二种方案只会减少产生这种错误,但不会从根本上避免这个问题,所以建议使用第一种方法,第二种可以作为辅助手段。
如果是在中间弹出的这个错误框,可能是由以下原因导致的:
The problem is likely due to the speed of the emulator so the network is too slow complete the communication
in a timely fashion.This can be due to:as you said you made some UI modifications, may be the size of images
are high)2.Your script may have a infinite or long loop, so that it takes too much of time to load.3.
You will be using too much of scripts (jQuery, iscroll, etc etc.. more number of plugins or scripts )
超时引起的问题可以增加超时时间,增加loadUrlTimeoutValue的值;如果是由图片引起的,建议可以通过降低图片的色位,大小等。
3)设置加载超时属性,在activity的onCreate方法中加入一行代码
@Overridepublic void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/home/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 10000);
或
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
}
Application Error - The connection to the server was unsuccessful.(file://android-asset/www/index.html)
解决:
参考原网址: http://blog.csdn.net/qq_20473985/article/details/68490438 http://blog.csdn.net/zhanqizi/article/details/41349959
正文:
最近用phonegap封装前端页面做的项目时,遇到一个问题,分享一下,希望可以帮到有同样问题的朋友。
在启动应用时会报错:
Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
导致这个错误的原因是:在安卓load页面时,页面需要加载的内容没有加载完。
所以需要增加超时时间,或加一个过渡页来避免这个问题。
方案如下:
1.在load页面时,先load一个空的页面,当页面load完成时,再加载现在的index.html,
步骤如下: 1)将你的"index.html"改名为"main.html";
2)创建一个新的"index.html",把下面的内容放到"index.html"中, <script type="text/javascript"> window.location="./main.html"; </script>.2.将LoadUrlTimeoutValue设置为50或60秒,默认是20秒(此方案只能减少这个错误,无法从源头解决问题),
在config.xml中增加下面这行:<preference name="loadUrlTimeoutValue" value="50000" />
注:第二种方案只会减少产生这种错误,但不会从根本上避免这个问题,所以建议使用第一种方法,第二种可以作为辅助手段。
如果是在中间弹出的这个错误框,可能是由以下原因导致的:
The problem is likely due to the speed of the emulator so the network is too slow complete the communication
in a timely fashion.This can be due to:as you said you made some UI modifications, may be the size of images
are high)2.Your script may have a infinite or long loop, so that it takes too much of time to load.3.
You will be using too much of scripts (jQuery, iscroll, etc etc.. more number of plugins or scripts )
超时引起的问题可以增加超时时间,增加loadUrlTimeoutValue的值;如果是由图片引起的,建议可以通过降低图片的色位,大小等。
3)设置加载超时属性,在activity的onCreate方法中加入一行代码
@Overridepublic void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/home/index.html");
super.setIntegerProperty("loadUrlTimeoutValue", 10000);
或
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
}
相关文章推荐
- Ionic-Android平台项目调试时出错:The connection to the server was unsuccessful
- Android App启动错误的问题(connection to the server was unsuccessful)
- Application Error - The connection to the server was unsuccessful.
- [置顶] Application Error - The connection to the server was unsuccessful.
- [Android_Bug]处理PhoneGap Application Error: "The connection to the server was unsuccessful.(file:///android_asset/www/index.html)"的错误
- 解决ionic3 android 运行出现Application Error - The connection to the server was unsuccessful
- 处理phonegap(cordova) application error the connection to the server was unsuccessful的错误
- PhoneGap开发出现 Application Error - The connection to the server was unsuccessful.
- 【错误】:Could not open JDBC Connection for transaction; nested exception is: Communications link failure;The last packet sent successfully to the server was 1 milliseconds ago
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of this service in the Microsogt M
- Firefox: Connection Interrupted | The connection to the server was reset while the page was loading
- VMware启动错误信息: The connection to the VMware USB Arbitration Service was unsuccessful
- VMware启动错误信息: The connection to the VMware USB Arbitration Service was unsuccessful
- Exception : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server
- the connection to the VMware USB Arbitration Service was unsuccessful.Please check the status of thi
- was unable to start within 45 seconds. If the server requires more time, try increasing the timeout
- FTP——the connection with the server was reset
- 解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法
- Server Tomcat v8.5 Server at localhost was unable to start within 45 seconds. If the server requires
- android中The connection to adb is down,ADB server didn't ACK 问题和解决