Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webview crash NullPointerException android.webkit.WebViewDatabase.initDatabase(WebViewDatabase.java:234)

I recieve from google play msg that my app crash, in the msg

java.lang.NullPointerException
at android.webkit.WebViewDatabase.initDatabase(WebViewDatabase.java:234)
at android.webkit.WebViewDatabase.init(WebViewDatabase.java:212)
at android.webkit.WebViewDatabase.access$000(WebViewDatabase.java:40)
at android.webkit.WebViewDatabase$1.run(WebViewDatabase.java:193)

I don't find in google or in stackoverflow similar probloem so I dont know why this crach, but I know that cause by webview.

like image 337
idan Avatar asked Jul 04 '13 21:07

idan


1 Answers

Looks to be the same as this issue here (plus potential workaround):

https://code.google.com/p/android/issues/detail?id=35204

I found the code for WebViewDatabase here (it's not exactly the same version, but there is enough context to get the picture):

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/WebViewDatabase.java#WebViewDatabase.initDatabase%28android.content.Context%29

If you look at the code for initDatabase(), there is a potential NPE on the line that I marked with "****". Note that the following line checks for NULL, so it looks to be a bit dumb:

 private void initDatabase(Context context) {
     try {
         mDatabase = context.openOrCreateDatabase(DATABASE_FILE, 0, null);
     } catch (SQLiteException e) {
         // try again by deleting the old db and create a new one
         if (context.deleteDatabase(DATABASE_FILE)) {
             mDatabase = context.openOrCreateDatabase(DATABASE_FILE, 0,
                     null);
         }
     }

     mDatabase.enableWriteAheadLogging(); ****

     // mDatabase should not be null,
     // the only case is RequestAPI test has problem to create db
     if (mDatabase == null) {
         mInitialized = true;
         notify();
         return;
like image 186
1800 INFORMATION Avatar answered Sep 28 '22 02:09

1800 INFORMATION