Reference.get()' on a null object reference 报错

使用mediaSession时报错

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 C a l l b a c k StubApi21.onCommand(MediaSessionCompat.java:955)
at
android.support.v4.media.session.MediaSessionCompatApi21 C a l l b a c k P r o x y . o n C o m m a n d ( M e d i a S e s s i o n C o m p a t A p i 21. j a v a : 164 ) a t a n d r o i d . m e d i a . s e s s i o n . M e d i a S e s s i o n 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)

以下是解决方案

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.

猜你喜欢

转载自blog.csdn.net/pengpeng952789/article/details/80857462