Like a lot of people, I'm developing a simple Android app that is just a Webview that opens my full responsive website, just to permit to find it, install it and launch it like a "real" app (I know you know why I'm doing that!). My web site uses CKEditor to permit user to create simple html pages and upload their images to put inside their pages. To do that I use the Responsive File Manager with CKEditor and all works fine if I open my website from Chrome or other browser on my phone (Android 9). But when I launch my Webapp, even if 90% of the site works fine, I have in the log several Javascript errors like:
I/chromium: [INFO:CONSOLE(305)] "Uncaught TypeError: $(...).fancybox is not a function"
I/chromium: [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'tools' of undefined" (it refers to this source code --> window.opener.CKEDITOR.tools.callFunction(a, e) )
and when I try to use the "upload image" or "select image" funcionality it doesn't works due to the above Javascript errors (it does nothing when I click the action button).
I already enabled Javascript, dom storage and access to all files and document using the webview settings, as suggested in other similar questions, but nothing worked for me.
My super-simple Android app:
public class MainActivity extends Activity {
private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
mWebView = new WebView(this);
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setAllowContentAccess(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
webSettings.setBlockNetworkLoads(false);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(false);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
mWebView.loadUrl("https://www.responsivefilemanager.com/demo.php");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
this.setContentView(mWebView);
}
}