Олег Місько
Олег Місько

Reputation: 370

MediaSessionCompat NullPointerException only on Android 8

fellow community!

So I have a problem in my application, that is using MediaSessionCompat.

The problem which is a crash occurs only on Android 8 version (8.1 too), but mostly on 8.0.0 on different devices.

Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference
   at android.support.v4.media.session.MediaSessionCompat$Callback$StubApi21.onCommand(MediaSessionCompat.java:955)
   at android.support.v4.media.session.MediaSessionCompatApi21$CallbackProxy.onCommand(MediaSessionCompatApi21.java:164)
   at android.media.session.MediaSession$CallbackMessageHandler.handleMessage(MediaSession.java:1352)
   at android.os.Handler.dispatchMessage(Handler.java:105)
   at android.os.Looper.loop(Looper.java:251)
   at android.app.ActivityThread.main(ActivityThread.java:6572)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

I've searched through Google's Forums, where this problem was reported previously and through StackOverflow and hadn't succeeded.

Can someone give some tips or advices?

Upvotes: 2

Views: 1480

Answers (1)

Олег Місько
Олег Місько

Reputation: 370

The problem was solved by updating to the latest support library version.

The answer was found somewhere deep in the bug-tracking forums of Google.

If someone will struggle with the same problem - try to update your support library version at least to the 27+ version.

Upvotes: 2

Related Questions