lateinit property completableDeferred has not been initialized
jvenditti opened this issue ยท 7 comments
While testing the library I ran into this issue (p.s. the library is awesome ๐):
Caused by kotlin.UninitializedPropertyAccessException: lateinit property completableDeferred has not been initialized
at com.eazypermissions.coroutinespermission.PermissionManager.onDestroy + 113(PermissionManager.kt:113)
at androidx.fragment.app.Fragment.performDestroy + 2825(Fragment.java:2825)
at androidx.fragment.app.FragmentManagerImpl.moveToState + 1028(FragmentManagerImpl.java:1028)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState + 1238(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState + 1303(FragmentManagerImpl.java:1303)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange + 2656(FragmentManagerImpl.java:2656)
at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy + 2641(FragmentManagerImpl.java:2641)
at androidx.fragment.app.FragmentController.dispatchDestroy + 329(FragmentController.java:329)
at androidx.fragment.app.FragmentActivity.onDestroy + 366(FragmentActivity.java:366)
at androidx.appcompat.app.AppCompatActivity.onDestroy + 233(AppCompatActivity.java:233)
...
Same issue but different source
used library com.sagar:coroutinespermission:2.0.1
Caused by kotlin.UninitializedPropertyAccessException: lateinit property completableDeferred has not been initialized
at com.eazypermissions.coroutinespermission.PermissionManager.onPermissionResult + 38(PermissionManager.java:38)
at com.eazypermissions.common.BasePermissionManager.onRequestPermissionsResult + 46(BasePermissionManager.java:46)
at androidx.fragment.app.FragmentActivity.onRequestPermissionsResult + 768(FragmentActivity.java:768)
at android.app.Activity.dispatchRequestPermissionsResult + 7787(Activity.java:7787)
at android.app.Activity.dispatchActivityResult + 7638(Activity.java:7638)
at android.app.ActivityThread.deliverResults + 4605(ActivityThread.java:4605)
at android.app.ActivityThread.handleSendResult + 4653(ActivityThread.java:4653)
at android.app.ActivityThread.-wrap19(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage + 1829(ActivityThread.java:1829)
at android.os.Handler.dispatchMessage + 106(Handler.java:106)
at android.os.Looper.loop + 198(Looper.java:198)
at android.app.ActivityThread.main + 7038(ActivityThread.java:7038)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 523(RuntimeInit.java:523)
at com.android.internal.os.ZygoteInit.main + 836(ZygoteInit.java:836)
@jvenditti @brnogz Can we have a scenario or steps that would cause this issue?
@jvenditti @brnogz Can we have a scenario or steps that would cause this issue?
I'll try to reproduce it today, if I do, i will update this issue. My only guess is onDestroy and onPermissionResult is part of fragment and regardless usage of this library, these methods can be invoked anytime by the system. So it is very low chance but possible that lateinit property can be never initialized before one of these methods called.
I couldn't reproduce it myself, however crash reports are still coming so I will add my own modified version of the library in my app.
Cool, I will check it at my end and will try to reproduce.
I think if fragment gets recreated by the system(due to memory constraints or some other reason) system will use the default constructor to initialize fragment again. A new instance won't have CompletableDeferred
initialize.
@brnogz @jvenditti Please go through PR for this fix.