Search code examples
javascriptandroidhtmlwebviewassets

Android webview not displaying html with external js links


I have used the following code to display a website that i have included in the assets directory in my android app:

WebView myWebView = (WebView)findViewById(R.id.myWebView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/my_site/index.html");

In the index.html file i have called some external js files. But the external js files are not being called. Why is this happening? I have loaded the same website locally from iOS, and it is working perfectly. What can I do to rectify this?


Solution

  • I was actually doing a HTML5 game using phaser.js. It seems like the only way out was cocoonjs. Didn't find any other solution. Why does android's webview doesn't show the game by default without using any wrappers? I had the same game working perfect in iOS and windows webview without using any kind of wrappers.