I'm writing an Android application which host a webview to load a webpage. I got a lot of errors like below in logcat:
Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
Please note that Javascript is executed well if it's not an inline script. For example, with an HTML file like below:
<htnl>
<head>
<script type="text/javascript" src="abc.js"></script>
</head>
<body>
<script type="text/javascript">
alert("This is inline script");
</script>
</body>
</html>
Script in abc.js is executed properly, but the inline script is refused to execute.
I understand that the webview refuses to execute inline Javascript due to "Contect Security Policy". But the webpage need to execute those inline scripts to function properly and I cannot make any change on the webpage.
This problem only KitKat (Android 4.4)
Is there any way to overcome this problem, modify "Content Security Policy" to allow inline script to be executed.