Error Inflating class

  • Antworten:4
  • OffenNicht stickyNicht beantwortet
  • Forum-Beiträge: 2

06.06.2016, 11:23:27 via Website

Ich habe ein Problem mit Error Inflating class und zwar wenn ich in der Navigationsbar auf ein Menü klicke um zu einem Intent zu gelangen kommt dieser Fehler und es stürzt ab. Ich bin mir nicht sicher was der genaue Fehler ist und habe hier mal das Logcat:

06-06 09:12:31.275 2786-2928/com.example.stefanbeka.medikationrichtig E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa1b56b0
06-06 09:12:42.006 2786-2928/com.example.stefanbeka.medikationrichtig E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa1b5720
06-06 09:12:44.777 2786-2928/com.example.stefanbeka.medikationrichtig E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa1b4300
06-06 09:12:48.261 2786-2786/com.example.stefanbeka.medikationrichtig E/InputEventSender: Exception dispatching finished signal.
06-06 09:12:48.262 2786-2786/com.example.stefanbeka.medikationrichtig E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
06-06 09:12:48.263 2786-2786/com.example.stefanbeka.medikationrichtig E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v4.widget.DrawerLayout.isDrawerOpen(int)' on a null object reference
at com.example.stefanbeka.medikationrichtig.Medikamente.onBackPressed(Medikamente.java:184)
at android.app.Activity.onKeyUp(Activity.java:2477)
at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
at android.app.Activity.dispatchKeyEvent(Activity.java:2730)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:513)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3820)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3981)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2253)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1874)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1865)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2230)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-06 09:12:48.264 2786-2786/com.example.stefanbeka.medikationrichtig E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.stefanbeka.medikationrichtig, PID: 2786
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v4.widget.DrawerLayout.isDrawerOpen(int)' on a null object reference
at com.example.stefanbeka.medikationrichtig.Medikamente.onBackPressed(Medikamente.java:184)
at android.app.Activity.onKeyUp(Activity.java:2477)
at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
at android.app.Activity.dispatchKeyEvent(Activity.java:2730)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:513)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3820)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3981)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2253)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1874)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1865)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2230)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-06 09:12:58.322 3259-3290/com.example.stefanbeka.medikationrichtig E/Surface: getSlotFromBufferLocked: unknown buffer: 0xae4b14d0

ACTIVITY:
image

CONTENT:
image

Fehler:
image

Ich bedanke mich im voraus für jede Hilfe.

Antworten
  • Forum-Beiträge: 2.243

06.06.2016, 12:15:49 via Website

06-06 09:12:48.263 2786-2786/com.example.stefanbeka.medikationrichtig E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v4.widget.DrawerLayout.isDrawerOpen(int)' on a null object reference 

Deine Drawer Member Variable ist null

Antworten
  • Forum-Beiträge: 2.243

06.06.2016, 12:52:55 via Website

Laut Stacktrace verwendest Du die Methode .isDrawerOpen in deiner onBackPrassed.

Die Variable an der du .isDrawerOpen aufrufst, ist null.

Wie du das änderst, musst Du dir halt anhand deines Anwendungsfalls überlegen.
Brauchst Du den Drawer, initialisiere die Variable, brauchst du ihn nicht, nimm den Aufruf raus.

Antworten
  • Forum-Beiträge: 434

06.06.2016, 13:59:25 via Website

Ein Beispiel wie man es fixen könnte...

if(drawerLayout == null) drawerLayout = (DrawerLayout) findViewById(R.id.deineId);

Wenns dann immer noch nicht geht, solltest du mal Build->Clean machen und checken ob die Namen der IDs und Layouts stimmen.

Open Source

Antworten

Empfohlene Artikel