androidandroid-webviewandroid-4.0-ice-cream-sandwichlinechart

Webview Showing error message while tried to load with Line chart report data: SYNTAX_ERR: Dom Exception 12


I've implemented google charts for generating Line Chart reports. It works fine in above ICS Devices. But in ICS web view is loading with an error message instead of expected line chart report.

In what case can web view shows this error on web page The error message is: SYNTAX_ERR: Dom Exception 12

And how could I resolve this error?

Exception Rising in ICS is Like

03-30 10:02:36.490: W/webcore(6343): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:2453)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.WebViewCore$EventHub.access$12400(WebViewCore.java:1197)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.WebViewCore.removeMessages(WebViewCore.java:2565)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.WebView.sendOurVisibleRect(WebView.java:3429)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:960)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.ZoomManager.access$2200(ZoomManager.java:57)
03-30 10:02:36.490: W/webcore(6343):    at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:1448)
03-30 10:02:36.490: W/webcore(6343):    at android.os.Handler.handleCallback(Handler.java:605)
03-30 10:02:36.490: W/webcore(6343):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 10:02:36.490: W/webcore(6343):    at android.os.Looper.loop(Looper.java:137)
03-30 10:02:36.490: W/webcore(6343):    at android.app.ActivityThread.main(ActivityThread.java:4507)
03-30 10:02:36.490: W/webcore(6343):    at java.lang.reflect.Method.invokeNative(Native Method)
03-30 10:02:36.490: W/webcore(6343):    at java.lang.reflect.Method.invoke(Method.java:511)
03-30 10:02:36.490: W/webcore(6343):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
03-30 10:02:36.490: W/webcore(6343):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
03-30 10:02:36.490: W/webcore(6343):    at dalvik.system.NativeStart.main(Native Method)

Please Help me to find out the solution.

Edit: Sample HTML:

<html>
<head>
    <meta name="viewport" content="target-densitydpi=device-dpi"/>
    <style type="text/css"></style>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">google.load("visualization", "1", {packages: ["corechart"]});
    google.setOnLoadCallback(drawChart);

    function drawChart() {
        var data = google.visualization.arrayToDataTable([
            ['Intervel', 'Weekly'], 
            ['01/23/2015 - 01/24/2015', 0.0], 
            ['01/25/2015 - 01/31/2015', 0.0], 
            ['02/01/2015 - 02/07/2015', 0.0], 
            ['02/08/2015 - 02/14/2015', 0.0], 
            ['02/15/2015 - 02/21/2015', 0.0], 
            ['02/22/2015 - 02/24/2015', 0.0]]);
        var options = {
            'legend': 'top',
            'pointSize': 10,
            'lineWidth': 3,
            series: {0: {color: '#7B9008'}},
            backgroundColor: 'transparent',
            vAxis: {
                textStyle: {fontSize: '18'},
                textColor: '#8B8585',
                gridlines: {color: '#CACACA'},
                baselineColor: '#CACACA'
            },
            hAxis: {
                textStyle: {fontSize: '18'},
                textColor: '#8B8585',
                gridlines: {color: '#CACACA'},
                baselineColor: '#CACACA'
            }
        };
        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    }</script>
</head>
<body style="background-color:transparent">
<div id="chart_div" style="width:100%; height:100%; text-align:left"></div>
</body>
</html>

Solution

  • The problem is that I've used webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null) to load HTML content. I replaced it with webView.loadData( data, "text/html", "UTF-8").

    loadDataWithBaseURL(): Loads the given data into this WebView, using baseUrl as the base URL for the content

    Here in place of base URL I've specified null. But I don't understand why it works in other android versions except in ICS.

    loadData(): Loads the given data into this WebView using a 'data' scheme URL.

    in my case I should use loadData().