How to fix the connection to the server was unsuccessful. (file ///android_asset/www/index.html)

后端 未结 8 769
借酒劲吻你
借酒劲吻你 2021-02-02 07:24

I\'ve added material icons to ionic2 app , and since then I get error \"\"The connection to the server was unsuccessful. (file:///android_asset/www/index.html)\"\" although the

相关标签:
8条回答
  • 2021-02-02 07:39

    As of now above solutions will work but the app will take time to load, instead of that you can simply add below in your MainActivity.java super.loadUrl("file:///android_asset/www/index.html");

    In MainActivity.java you have to comment below code loadUrl(launchUrl);

    public class MainActivity extends CordovaActivity
    {
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    
            // enable Cordova apps to be started in the background
            Bundle extras = getIntent().getExtras();
            if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
                moveTaskToBack(true);
            }
    
            // Set by <content src="index.html" /> in config.xml
            //loadUrl(launchUrl);
            super.loadUrl("file:///android_asset/www/index.html");
    
        }
    }
    
    0 讨论(0)
  • 2021-02-02 07:39

    Please check your device version ionic not properly work on android < 4.4.4 version you could try this above 4 version if you want to work with 4.* version you could install cordova-crosswalk plugin

    0 讨论(0)
  • 2021-02-02 07:39

    I add plugin:

    cordova plugin add cordova-plugin-crosswalk-webview
    

    then,

    ionic cordova platform rm android
    ionic cordova platform add android
    ionic cordova build android (or Run)
    
    0 讨论(0)
  • 2021-02-02 07:44

    Just need to also make sure that your mobile device is connected to the same wifi as your computer.

    0 讨论(0)
  • 2021-02-02 07:46

    Add <preference name="loadUrlTimeoutValue" value="60000" /> To config.xml

    0 讨论(0)
  • 2021-02-02 07:50

    1- Rename your index.html to “main.html”

    2- Create a new “index.html” and put the following content into it:

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

    3- Rebuild your app! No more errors!

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