java.lang.NullPointerException in some cases
Closed this issue · 1 comments
Marukohe commented
Hello, I find in some cases, the app will crash because of NPE problem.
Here is the stack trace:
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:220)
at java.util.Arrays$ArrayList.<init>(Arrays.java:4248)
at java.util.Arrays.asList(Arrays.java:4235)
at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:165)
at com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities.generator.QrGeneratorDisplayActivity.newErrorCorrectionAdapter(QrGeneratorDisplayActivity.java:179)
at com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities.generator.QrGeneratorDisplayActivity.onResume(QrGeneratorDisplayActivity.java:232)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)
at android.app.Activity.performResume(Activity.java:8422)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4793)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4836)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
After reading the soure code, I may find the reason. When QrGeneratorDisplayActivity#onResume
, QrGeneratorDisplayActivity#newErrorCorrectionAdapter
will be invoked. The parameter currentErrorCorrections
in some cases will be assigned to null in QrGeneratorDisplayActivity#updateDropDownMenus
. So a NPE happens in some cases.
Here is a video which can trigger the crash.
codescanner.mp4
Device : Google pixel 4
OS: Android 12.
udenr commented
Thanks for the detailed description and the video. I will have a look at it.