i am trying to find it a way from last few hours and couldn't done.
Issue: I have one html page and a webGL file(three.js file). I need to open this html file in Android Webview. WebView is failed to load the html page.
Below is the code that i have tried
WebSettings settings = webView.getSettings();
webView.addJavascriptInterface(this, "Android");
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setUseWideViewPort(true);
webView.setWebChromeClient(new WebChromeClient(){
});
webView.loadUrl("file://" + Environment.getExternalStorageDirectory() + "/Android/index.html");
I had placed all my resources inside sdcard.
Error log:
"Uncaught ReferenceError: $ is not defined", source: file:///storage/emulated/0/Android/all.min.js (17)
"THREE.WebGLRenderer", source: file:///storage/emulated/0/Android/all.min.js (11)
"THREE.WebGLRenderer: OES_texture_float extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer: OES_texture_float_linear extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer: OES_texture_half_float extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer: OES_texture_half_float_linear extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer: ANGLE_instanced_arrays extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer: OES_element_index_uint extension not supported.", source: file:///storage/emulated/0/Android/all.min.js (12)
"THREE.WebGLRenderer:", source: file:///storage/emulated/0/Android/all.min.js (12)
"XMLHttpRequest cannot load file:///storage/emulated/0/Android/res/sky.ctm. Cross origin requests are only supported for protocol schemes:
http, data, chrome, https.", source: file:///storage/emulated/0/Android/index.html (0)
"Uncaught TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null", source: file:///storage/emulated/0/Android/all.min.js (16)
Any one can suggest me what i have to do?
try turning on the following settings:
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With