Karumi / Dexter

Android library that simplifies the process of requesting permissions at runtime.
http://karumi.com
Apache License 2.0
5.23k stars 671 forks source link

Failure delivering result ResultInfo #243

Closed TeoChopi closed 4 years ago

TeoChopi commented 4 years ago

Actual behaviour

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.medux.configwifiprobe/com.karumi.dexter.DexterActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       at android.app.ActivityThread.deliverResults(ActivityThread.java:4013)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:4056)
       at android.app.ActivityThread.access$1400(ActivityThread.java:196)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1588)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:210)
       at android.app.ActivityThread.main(ActivityThread.java:5982)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:852)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)

Version of the library

5.0.0

pedrovgs commented 4 years ago

Hi @TeoChopi could you please provide more information about this error? When is the exception triggered? What permission are you requested? Are you still facing this issue with the library version 6.0.0.? What are the steps to reproduce it? Do you have an example repository reproducing the error?

GuilhE commented 4 years ago

I think I may have the same issue in v5.0.0. Personally I never caught it, Fabric's log:

Fatal Exception: java.lang.RuntimeException Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {.../com.karumi.dexter.DexterActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.finish()' on a null object reference

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {.../com.karumi.dexter.DexterActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.finish()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:4617)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659)
       at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7078)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Caused by java.lang.NullPointerException Attempt to invoke virtual method 'void android.app.Activity.finish()' on a null object reference

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.finish()' on a null object reference
at com.karumi.dexter.DexterInstance.onPermissionsChecked(DexterInstance.java:27)
at com.karumi.dexter.DexterInstance.updatePermissionsAsGranted(DexterInstance.java:26)
at com.karumi.dexter.DexterInstance.onPermissionRequestGranted(DexterInstance.java)
at com.karumi.dexter.Dexter.onPermissionsRequested(Dexter.java:4)
at com.karumi.dexter.DexterActivity.onRequestPermissionsResult(DexterActivity.java:51)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7981)
at android.app.Activity.dispatchActivityResult(Activity.java:7803)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4610)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4659)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7078)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Device Brand: samsung Model: Galaxy A20e Orientation: Portrait RAM free: 723.34 MB Disk free: 1.55 GB

Operating System Version: 9 Orientation: Portrait Rooted: No

About the permission itself, I'm not 100% sure, but I think it was for location. I think it could be related with #221

pedrovgs commented 4 years ago

I'm going to send a PR with a tentative fix and once it's merged and release we will close the issue. We are not able to reproduce this error and our uses either so this will be a tentative fix. Please after releasing our new version update your app and let us know if you can still reproduce the error. Please, if the PR I've sent doesn't fix the error, please reopen this issue.

pedrovgs commented 4 years ago

I can confirm Dexter 6.0.1 fixed this issue. If someone else would check it out, that'd be awesome.

GuilhE commented 4 years ago

Olá Pedro,

Personally I could never reproduce this issue, I've only seen it on Fabric. I'll have to issue an update and wait for a period of time to see if it will get caught. But as you stated - and as your code shows - this is fixed :)

Thanks for your support.

Sumit123rox commented 3 years ago

I got this Error in Dexter version 6.2.1

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.nojoto.cinco/com.karumi.dexter.DexterActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.ActivityThread.deliverResults(ActivityThread.java:3929) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3972) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1537) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

Caused by java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1703) at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1743) at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321) at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286) at com.nojoto.cinco.activity.InviteAndFollowFriendsLoopActivity.openFollowFriendsFragment(InviteAndFollowFriendsLoopActivity.kt:118) at com.nojoto.cinco.fragments.inviteFollowLoopFragments.sync.SyncContactFragment.fetchUserContacts(SyncContactFragment.kt:72) at com.nojoto.cinco.fragments.inviteFollowLoopFragments.sync.SyncContactFragment.access$fetchUserContacts(SyncContactFragment.kt:31) at com.nojoto.cinco.fragments.inviteFollowLoopFragments.sync.SyncContactFragment$checkForStoragePermissions$1.onPermissionGranted(SyncContactFragment.kt:90) at com.karumi.dexter.MultiplePermissionsListenerToPermissionListenerAdapter.onPermissionsChecked(SourceFile) at com.karumi.dexter.MultiplePermissionListenerThreadDecorator$1.run(SourceFile) at com.karumi.dexter.MainThread.execute(SourceFile) at com.karumi.dexter.MultiplePermissionListenerThreadDecorator.onPermissionsChecked(SourceFile) at com.karumi.dexter.DexterInstance.onPermissionsChecked(SourceFile) at com.karumi.dexter.DexterInstance.updatePermissionsAsGranted(SourceFile) at com.karumi.dexter.DexterInstance.onPermissionRequestGranted(SourceFile) at com.karumi.dexter.Dexter.onPermissionsRequested(SourceFile) at com.karumi.dexter.DexterActivity.onRequestPermissionsResult(SourceFile) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6625) at android.app.Activity.dispatchActivityResult(Activity.java:6504) at android.app.ActivityThread.deliverResults(ActivityThread.java:3925) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3972) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1537) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)