A network error in Phonegap on Android?

后端 未结 6 1755
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-15 05:54

I get this error. What should I do?

The path is valid and I\'ve checked it. And I\'ve made a clean and rebuilt the app again, and so forth. I really

相关标签:
6条回答
  • 2021-01-15 06:35

    i had this problem and i fixed it like this..

    super.loadUrl("file:///android_asset/www/index.html"); 
    

    to

    super.loadUrl("file:///android_asset/www/index.htm");
    
    0 讨论(0)
  • 2021-01-15 06:38

    Check your asset/www/ folder. Check the index.html file is there.

    0 讨论(0)
  • 2021-01-15 06:39

    You might need to use IceCreamCordovaWebViewClient

    @Override
        public void init() {
        super.init(webView, new IceCreamCordovaWebViewClient(this, webView), new CordovaChromeClient(this, webView));
    }
    
    0 讨论(0)
  • 2021-01-15 06:44

    I found a really good solution to this online.

    What you basically need to do is to move the contents of index.html to another file, say app.html.

    Then have the following code in your original index.html:

    <!doctype html>
    <html>
    <head>
       <title>your app name</title>
    </head>
    <body>
       <script>
           window.location='./app.html';
       </script>
    </body>
    </html>
    

    The connection to the server won't timeout anymore and the app should load successfully.

    Now I didn't come up with this great idea. All credit goes to Robert Kehoe:

    https://www.robertkehoe.com/2013/01/fix-for-phonegap-connection-to-server-was-unsuccessful/

    Doing this helped me solve a similar problem with my own Android phonegap application...

    0 讨论(0)
  • 2021-01-15 06:48

    Raj Patel answer works! should use super.loadUrl("file:///android_asset/www/index.html"); although the folder in called assets in eclipse

    0 讨论(0)
  • 2021-01-15 06:54

    check your www folder, I think there is no index.hmtl in there

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