android在java.util.Objects.requireNonNull中获取空指针异常(Objects.java:203)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android在java.util.Objects.requireNonNull中获取空指针异常(Objects.java:203)相关的知识,希望对你有一定的参考价值。
我正在阅读编写字符串数组并在Recycler视图中显示它们。在显示它们之前,我正在使用Collections.reverse(Arrays.asList(FilePathStrings))来反转顺序;以下是我得到的例外情况:
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Arrays$ArrayList.<init>(Arrays.java:3826)
at java.util.Arrays.asList(Arrays.java:3813)
at com.example.soberapps.nightcamera.b.c.a(Unknown Source)
at android.support.v4.app.i.b(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.o.e(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.c.d(Unknown Source)
at android.support.v4.app.o.b(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.o.b(Unknown Source)
at android.support.v4.app.o.h(Unknown Source)
at android.support.v4.app.o$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at androidx.test.espresso.base.Interrogator.a(Interrogator.java:19)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:164)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:156)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:34)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:75)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:50)
at androidx.test.espresso.action.Tap.c(Tap.java:8)
at androidx.test.espresso.action.Tap.a(Tap.java:18)
at androidx.test.espresso.action.Tap$1.b(Tap.java:3)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:78)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:94)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
错误报告崩溃
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1689)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerProxy.java:5217)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:97)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
答案
Arrays.asList(null)
抛出这个例外。您的参数(FilePathStrings
)等于null。
以上是关于android在java.util.Objects.requireNonNull中获取空指针异常(Objects.java:203)的主要内容,如果未能解决你的问题,请参考以下文章
int 上的余数运算符导致 java.util.Objects.requireNonNull?