Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview: "Uncaught TypeError: Cannot read property 'getItem' of null"

I am creating a simple android app which has a webview which should display a url. When I give the url as google.com or facebook.com it loads properly but when I give my url(qbo.intuit.com), it doesn't load and gives the "Uncaught TypeError: Cannot read property 'getItem' of null" error. I am pasting my code here well. I am using Compile sdk version: API 22: Android 5.1 (Lollipop), Version- Android Studio 1.4, Build Number: AI-141.2288178, Android SDK Tools: 24.4.0, jdk1.7.0_80. A similar question exists but it did not help me. Please help I am new to android. MainActivity.java

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String url= "https://qbo.intuit.com/";
    WebView view= (WebView) this.findViewById(R.id.webView);

     final WebViewClient client = new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }

    };

        WebSettings settings = view.getSettings();
        settings.setJavaScriptEnabled(true);
    view.setWebViewClient(client);
        view.loadUrl(url);


}

AndriodManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

like image 286
Sonal Avatar asked Oct 12 '15 11:10

Sonal


1 Answers

you need to do

WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);

see details ERROR/Web Console: Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844

like image 125
Ashish Rawat Avatar answered Oct 16 '22 16:10

Ashish Rawat