java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference

Stack Overflow | HARSHIL JAIN | 8 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Getting error while executing MediaPlayer.start() method

    Stack Overflow | 8 months ago | HARSHIL JAIN
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference

      at com.example.android.miwok.NumbersActivity$1.onItemClick()
    2. com.example.android
      NumbersActivity$1.onItemClick
      1. com.example.android.miwok.NumbersActivity$1.onItemClick(NumbersActivity.java:46)
      1 frame
    3. Android Platform
      ViewGroup.dispatchTouchEvent
      1. android.widget.AdapterView.performItemClick(AdapterView.java:310)
      2. android.widget.AbsListView.performItemClick(AbsListView.java:1188)
      3. android.widget.AbsListView$PerformClick.run(AbsListView.java:3231)
      4. android.widget.AbsListView.onTouchUp(AbsListView.java:4176)
      5. android.widget.AbsListView.onTouchEvent(AbsListView.java:3887)
      6. android.view.View.dispatchTouchEvent(View.java:8593)
      7. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2513)
      8. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2157)
      9. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
      10. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
      11. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
      12. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
      13. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
      14. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
      15. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
      16. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
      17. android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
      18. android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
      18 frames
    4. Android
      PhoneWindow.superDispatchTouchEvent
      1. com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2484)
      2. com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1800)
      2 frames
    5. Android Platform
      Activity.dispatchTouchEvent
      1. android.app.Activity.dispatchTouchEvent(Activity.java:2797)
      1 frame
    6. Android v7
      WindowCallbackWrapper.dispatchTouchEvent
      1. android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
      1 frame
    7. Android
      PhoneWindow$DecorView.dispatchTouchEvent
      1. com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2445)
      1 frame
    8. Android Platform
      ActivityThread.main
      1. android.view.View.dispatchPointerEvent(View.java:8799)
      2. android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4662)
      3. android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4520)
      4. android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4034)
      5. android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4087)
      6. android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4053)
      7. android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4190)
      8. android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4061)
      9. android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4247)
      10. android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4034)
      11. android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4087)
      12. android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4053)
      13. android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4061)
      14. android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4034)
      15. android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6463)
      16. android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6437)
      17. android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6390)
      18. android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6622)
      19. android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
      20. android.os.MessageQueue.nativePollOnce(Native Method)
      21. android.os.MessageQueue.next(MessageQueue.java:148)
      22. android.os.Looper.loop(Looper.java:151)
      23. android.app.ActivityThread.main(ActivityThread.java:5649)
      23 frames
    9. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    10. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
      2 frames