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

后端 未结 16 1774
小蘑菇
小蘑菇 2020-11-28 01:28

App Dies On Startup (connection to the server was unsuccessful)

I have an Android application that I\'m writing using PhoneGap BUILD. The app was working fine earli

相关标签:
16条回答
  • 2020-11-28 02:27

    As you said, there are many duplicate questions on the same topic. Any how explaining your situation.

    The problem might be solved by adding a timeout to call your index.html

    ie you need to add super.setIntegerProperty("loadUrlTimeoutValue", 70000); in your activity.java file ( inside src/com/yourProj/--/youractivity.java) above this line: super.loadUrl("file:///android_asset/www/index.html");

    Explanation:

    This can be happened due to the following reasons

    The core reason: 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:

    1. Your code/data/image is of too much of size ( I guess in your case you are using some images ,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 )
    0 讨论(0)
  • 2020-11-28 02:28

    Extending loading Timeout Limit will not solve the problem which caused the error, it just will avoid the system to show the message but performance will be affected whatsoever.

    Actual reason: You may be linking files or images to remote locations, and those resources are taking too long to load. (this is likely the most common error)

    Definitive solution: move all the scripts, images and css needed to some local folders and load them locally ...

    Performance will be increased and error will be effectively solved.

    0 讨论(0)
  • 2020-11-28 02:28

    fixing this on an ionic app, simply add

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

    to your config.xml file immediately after this line

    <platform name="android">
    
    0 讨论(0)
  • 2020-11-28 02:29

    If you are using visual studio. After changing config.xml sometimes you need this

    clean build solution rebuild your app

    It is working for me.

    0 讨论(0)
提交回复
热议问题