0

I have stored a website locally in my assets folder (i.e. HTML, CSS and Javascript files). Using a WebView, I can display the website on any phone I tried with Android 9, emulated or hardware. But when the API is lower than 28, the WebView is blank (apparently because the Javascript does not load; the website needs Javascript to display anything). This is the code I use:

webView = (WebView) findViewById(R.id.webview);
webView.loadUrl("file:///android_asset/website.html");

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);
webSettings.setSupportZoom(true);
webSettings.setDefaultTextEncodingName("utf-8");

webView.addJavascriptInterface(jsInterface, "JSInterface");

What can be the error?

Sid
  • 563
  • 1
  • 10
  • 28

1 Answers1

-1

I resolved the issue by fixing an error in the JavaScript file; I had used "append" instead of "appendChild" somewhere, which was apparently not a problem for API 28+, but resulted in an error otherwise.

Sid
  • 563
  • 1
  • 10
  • 28