leandroBorgesFerreira / LoadingButtonAndroid

A button to substitute the ProgressDialog
MIT License
1.95k stars 214 forks source link

lateinit property initialState has not been initialized in version 2.1.4 #148

Open Ahmed-Adel-Ismail opened 5 years ago

Ahmed-Adel-Ismail commented 5 years ago

the same issue here : https://github.com/leandroBorgesFerreira/LoadingButtonAndroid/issues/119

is happening on version 2.1.4, not fixed yet ... these are the logs :

Caused by: kotlin.UninitializedPropertyAccessException: lateinit property initialState has not been initialized at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.access$getInitialState$p(CircularProgressButton.kt:21) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:70) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:21) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.getMorphAnimator(Unknown Source:7) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.dispose(CircularProgressButton.kt:171) at java.lang.reflect.Method.invoke(Native Method) at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185) at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361) at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:316) at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334) at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145) at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131) at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:123) at androidx.lifecycle.ReportFragment.onDestroy(ReportFragment.java:108) at android.app.Fragment.performDestroy(Fragment.java:2870) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1424) at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1554) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1616) at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3044) at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3024) at android.app.FragmentController.dispatchDestroy(FragmentController.java:244) at android.app.Activity.performDestroy(Activity.java:7251) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1249) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4492) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4523) at android.app.ActivityThread.-wrap5(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1683) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:6701) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:249) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

mhelmi commented 5 years ago

The issue here, still happening on 2.1.5

mhelmi commented 5 years ago

The problem happened for me when I observe loadingLiveData to start or stop animation if I transaction another fragment and back to the fragment that included the CircleProgressButton it's start to observe loadingLiveData variable again and get the last value and try to revert morph animation while the current state is stop so it's crashes and give the above error.

I solved this problem by check the state before morph, so the btn can't start morph while it's not morph any more. The working check solution for my case was:

if (btn.getState().equals(State.MORPHING) || btn.getState().equals(State.PROGRESS)) btn.startMorphRevertAnimation();

leandroBorgesFerreira commented 5 years ago

Sorry, taking so long for the reply. I'll take a look as soon as I can.

uncledoc commented 5 years ago

I have the same issue on android 4.2.2

chetan3333 commented 4 years ago

The same issue is happening to me as well

mhelmi commented 4 years ago

it there any update for this issue? @leandroBorgesFerreira I have faced it when I am using btn in the adapter and try to update adapter to start loading

leandroBorgesFerreira commented 3 years ago

Sorry for the late response... I can't reproduce it in the sample app. I fire the start animation inside the onCreate of an activity and it works just fine =|

Maybe inside a fragment... Let's see.

piotrwroblewski90 commented 3 years ago

I' have the same issue in version 2.2.0

josechagas commented 3 years ago

I' have the same issue in version 2.2.0. Please take a look at this stacktrace

Caused by kotlin.UninitializedPropertyAccessException: lateinit property initialState has not been initialized at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.access$getInitialState$p(CircularProgressButton.kt:21) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:70) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:21) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.getMorphAnimator(:7) at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.dispose(CircularProgressButton.kt:171) at java.lang.reflect.Method.invoke(Method.java) at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194) at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185) ....

pacifire commented 3 years ago

Same issue...

Got Stacktrace from Crashlytics console.

Caused by kotlin.UninitializedPropertyAccessException: lateinit property initialState has not been initialized
       at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.access$getInitialState$p(CircularProgressButton.kt:21)
       at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:70)
       at br.com.simplepass.loadingbutton.customViews.CircularProgressButton$morphAnimator$2.invoke(CircularProgressButton.kt:21)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
       at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.getMorphAnimator(:7)
       at br.com.simplepass.loadingbutton.customViews.CircularProgressButton.dispose(CircularProgressButton.kt:171)
       at java.lang.reflect.Method.invoke(Method.java)
       at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216)
       at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194)
       at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185)
       at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:37)
       at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
       at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:316)
       at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334)
       at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
       at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
       at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:68)
       at androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:144)
       at androidx.lifecycle.ReportFragment.onDestroy(ReportFragment.java:134)
       at android.app.Fragment.performDestroy(Fragment.java:2782)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1451)
       at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1581)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1642)
       at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3051)
       at android.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3031)
       at android.app.FragmentController.dispatchDestroy(FragmentController.java:248)
       at android.app.Activity.performDestroy(Activity.java:7521)
       at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1307)
       at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4502)
       at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4535)
       at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:201)
       at android.app.ActivityThread.main(ActivityThread.java:6826)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
ChhaiHout commented 3 years ago

It seem like I could prevent that crash by calling button to dispose in onDestroyView : override fun onDestroyView() { super.onDestroyView() progressButton.dispose() } FYI : use in Fragment

This crash happened when I call dispose in onDestroy : override fun onDestroy() { super.onDestroy() progressButton.dispose() }