Trying to add the animation on chapter 6. Android Studio doesn’t give any error and the app runs, but when I press the cheat button (open CheatActivity) the app just crashes. From the logcat I found this
Caused by: java.lang.IllegalStateException: Cannot start this animator on a detached view!
at android.view.RenderNode.addAnimator(RenderNode.java:824)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:295)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:280)
at android.animation.RevealAnimator.<init>(RevealAnimator.java:37)
at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:71)
at android.bignerdranch.com.CheatActivity.onCreate(CheatActivity.java:64)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
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:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I tried to look at line 64 (at android.bignerdranch.com.CheatActivity.onCreate(CheatActivity.java:64)) but doesn’t seem anything wrong there. And I checked for typos, didn’t find any.