Android Webview not working on Android 4.4

user3241778 picture user3241778 · Jan 29, 2014 · Viewed 18.4k times · Source

I am developing an Android application based on a Webview. All is working fine on Android 4.1 but on 4.4 it throws this errors.

01-29 11:16:03.075: E/eglCodecCommon(2179): glUtilsParamSize: unknow param 0x00000bd0 01-29 11:16:03.095: E/eglCodecCommon(2179): ** ERROR unknown type 0x10037 (glSizeof,72)

If I uncomment this line it' working but (logically) not showing anything

webview.loadUrl("file:///android_asset/html/index.html");

The Webview config code looks like this.

    webview = new WebView(this);

        webview.clearCache(true);
        webview.clearHistory();
        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webview.setWebViewClient(new WebViewClient());
        //webview.setWebChromeClient(new WebChromeClient());
        webview.addJavascriptInterface(new JavaScriptInterface(this), "Android");

        setContentView(webview);
webview.loadUrl("file:///android_asset/html/index.html");

The HTML code is exactly

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

        <meta name="description" content="">
        <meta name="author" content="">


        <title>My Web App</title>

        <script src="../js/jquery.js"></script>
        <script src="../js/hammer.js"></script>
        <script src="../js/lightboxes.js"></script>
        <link href="../css/main.css" rel="stylesheet">
        <link href="../css/lightboxes.css" rel="stylesheet">


        <script type="text/javascript">

            activeId = "contentOne";
            passiveId = "contentTwo";
            swiping = false;

            function changeElements()
            {
                $("#" + passiveId).css("display", "none");
                $("#" + passiveId).css("-webkit-transition", "-webkit-transform 0s linear");
                $("#" + passiveId).css("-webkit-transform", "translate(150%,0)");
                setTimeout(function() {
                    $("#" + passiveId).css("display", "block");
                    $("#" + passiveId).css("-webkit-transition", "-webkit-transform 0.25s ease-in-out");
                    swiping = false;

                }, 10);

            }

            function nextPhrase()
            {
                if (!swiping)
                {
                    swiping = true;
                    $("#" + activeId).css("-webkit-transform", "translate(-101%,0)");
                    $("#" + passiveId).css("-webkit-transform", "translate(2.5%,0)");


                    var result = Android.getPhrase();

                    document.getElementById(passiveId + "Text").textContent = result;
                    tempId = activeId;
                    activeId = passiveId;
                    passiveId = tempId;
                    setTimeout(changeElements, 600);
                }


                //$("#"+passiveId).css("-webkit-transition", "-webkit-transform 0.1s linear");
                //$("#"+passiveId).css("-webkit-transform", "translate(-100%,0)");
                //$("#"+passiveId).css("-webkit-transition", "-webkit-transform 0.6s ease-in-out");



                //document.getElementById("next").style.backgroundColor="blue"; 
            }

            function rel()
            {
                document.getElementById("next").style.backgroundColor = "#FFF";
            }

            function changeColor(el)
            {

                document.getElementById("next").style.backgroundColor = "#EEE";
            }





        </script> 

    </head>

    <body>

        <div id="contentHeader">
            Never I have ever ...
        </div>
        <div id="container">
            <div id="contentOne">

                <div id="contentOneText">

                </div>
            </div>
            <div id="contentTwo">

                <div id="contentTwoText">

                </div>
            </div>

        </div>
        <div id="headNav">
            <div class="navElement" id="next" >
                <div class="elName">
                    Next
                </div>
            </div>
        </div>


        <div id="proposalLightbox">sdfsdfasfasdf</div>
        <div id="fade"></div> 

        <script>


            Hammer(document).on("dragleft", function(e) {

                nextPhrase();
            });



            document.getElementById('next').ontouchstart = function(eve) {

                nextPhrase();
                document.getElementById("next").style.backgroundColor = "#EEE";
            }

            document.getElementById('next').ontouchend = function(eve) {
                //alert()
                document.getElementById("next").style.backgroundColor = "#FFF";
            }
            var result = Android.getPhrase();

            document.getElementById(activeId + "Text").textContent = result;



            function testEcho(par)
            {
                alert(par);
            }

            function openProposeDialog(par)
            {
                showLightbox("proposalLightbox");
            }

            document.getElementById('fade').ontouchstart = function(eve) {

                closeLightboxes();
            }


            //nextPhrase();
        </script>

    </body>
</html>

And the Java-Javascript interface is

public class JavaScriptInterface {
        Context mContext;


        JavaScriptInterface(Context c) {
            mContext = c;
        }


        public String showToast(String toast) {
            Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
            return toast;
        }

        public String getPhrase() {

            String phrase = "";
            //phrase = dataHandler.getRandomPhrase();
            return phrase;
        }
    }

Thanks a lot in advance

Answer

rajahsekar picture rajahsekar · Jan 29, 2014

please check new kitkat api web view functionallity has changed

http://developer.android.com/guide/webapps/migrating.html