guolindev / PermissionX

An open source Android library that makes handling runtime permissions extremely easy.
Apache License 2.0
3.53k stars 406 forks source link

PermissionBuilder.grantedPermissions 空指针 #10

Closed lucers closed 4 years ago

lucers commented 4 years ago

发生机型:VIVO V1821A 与 OPPO R11 系统版本:Android 9(vivo),Android 8.1.0(oppo)

ava.lang.NullPointerException

Attempt to read from field 'java.util.Set com.permissionx.guolindev.request.PermissionBuilder.grantedPermissions' on a null object reference

guolindev commented 4 years ago

应该是被系统回收导致的空指针,有具体的堆栈信息吗?我看看在哪里加入空指针的保护比较合适。

lucers commented 4 years ago

1 java.lang.RuntimeException:Failure delivering result ResultInfo{who=@android:requestPermissions:, request=65537, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.sjzf.location/com.sjzf.location.ui.activity.AddAttentionActivity}: java.lang.NullPointerException: Attempt to read from field 'java.util.Set com.permissionx.guolindev.request.PermissionBuilder.grantedPermissions' on a null object reference 2 android.app.ActivityThread.deliverResults(ActivityThread.java:5587) 3 ...... 4 Caused by: 5 java.lang.NullPointerException:Attempt to read from field 'java.util.Set com.permissionx.guolindev.request.PermissionBuilder.grantedPermissions' on a null object reference 6 com.permissionx.guolindev.request.InvisibleFragment.onRequestNormalPermissionsResult(InvisibleFragment.java:125) 7 com.permissionx.guolindev.request.InvisibleFragment.onRequestPermissionsResult(InvisibleFragment.java:97) 8 androidx.fragment.app.FragmentActivity.onRequestPermissionsResult(FragmentActivity.java:768) 9 android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8566) 10 android.app.Activity.dispatchActivityResult(Activity.java:8416) 11 android.app.ActivityThread.deliverResults(ActivityThread.java:5580) 12 android.app.ActivityThread.handleSendResult(ActivityThread.java:5628) 13 android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 14 android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) 15 android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) 16 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473) 17 android.os.Handler.dispatchMessage(Handler.java:110) 18 android.os.Looper.loop(Looper.java:219) 19 android.app.ActivityThread.main(ActivityThread.java:8347) 20 java.lang.reflect.Method.invoke(Native Method) 21 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 22 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

guolindev commented 4 years ago

已在代码中加入空指针保护,会随着下个版本的发布修复此问题,谢谢支持。