0

I am trying to develop a dictionary app using a predefined database SQLite here is the logs while its crashed.

2019-11-23 08:26:40.432 16132-16349/offline.english.dictionary W/CrashlyticsCore: Cannot send reports. Settings are unavailable.
2019-11-23 08:26:40.433 16132-16132/offline.english.dictionary E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.database.CursorWindow.getNumRows()' on a null object reference
        at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
        at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:149)
        at android.support.v4.widget.CursorAdapter.getCount(CursorAdapter.java:217)
        at android.widget.AutoCompleteTextView$PopupDataSetObserver$1.run(AutoCompleteTextView.java:1416)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

Here is the SQLITECURSOR.java which showed error line:162

catch (RuntimeException ex) {
        closeWindow();
        throw ex;
    }
}

This is SQLiteCursor.java:149 as per the crash log

 mCount = mQuery.fillWindow(mWindow, requiredPos, requiredPos, true);

This is CursorAdapter.java:217 as per the crash log

private final Runnable updateRunnable = new Runnable() {
        @Override
        public void run() {
            final AutoCompleteTextView textView = mViewReference.get();
            if (textView == null) {
                return;
            }
            final ListAdapter adapter = textView.mAdapter;
            if (adapter == null) {
                return;
            }
            textView.updateDropDownForFilter(adapter.getCount());
        }
    };
  }
}

This is Handler.java:873,99 as per the crash log

 private static void handleCallback(Message message) {
    message.callback.run();
}
public void dispatchMessage(Message msg) {
    if (msg.callback != null) {
        handleCallback(msg);
    } else {
        if (mCallback != null) {
            if (mCallback.handleMessage(msg)) {
                return;
            }
        }
        handleMessage(msg);
    }
}

This is Looper.java:214 as per the crash report.

if (logSlowDispatch) {
            showSlowLog(slowDispatchThresholdMs, dispatchStart, dispatchEnd, "dispatch", msg);
        }

        if (logging != null) {
            logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
        }
Jacks
  • 803
  • 1
  • 6
  • 16
  • a minimum reproducible example would make this digestible. its not so much fun starting at a ton of code with things that aren't really relevant to the question – Kaushik Burkule Nov 23 '19 at 06:52
  • please see this question this may help u https://stackoverflow.com/a/32333895/10239870 – Arunachalam k Nov 23 '19 at 06:52
  • Sorry For Bothering you man but i added this code because it doesn't work only on my android device only maybe because its rooted but worked on other devices, so i found stackoverflow my only place to seek help thanks – Moustafa Asaad Nov 23 '19 at 07:13
  • We expect you to find the null pointer so you can prevent that null pointer exception. Then we can talk further. – blackapps Nov 23 '19 at 10:55

0 Answers0