Restarter must be created only during owner's initialization stage transition
Asked Answered
H

0

6

I am trying to implement transitions in my app for the first time, but it keeps crashing with this message

Restarter must be created only during owner's initialization stage transition

This is how I add the fragment:

        activity.subFm.beginTransaction()
            .setCustomAnimations(
                R.anim.slide_in_up,
                R.anim.slide_out_down,
                R.anim.slide_in_up,
                R.anim.slide_out_down
            )
            .replace(R.id.feed_subcontents_frame_container, activity.searchFragment, "searchFragment")
            .addToBackStack("searchFragment").commit()

I tried also like this:

        activity.subFm.beginTransaction()
            .setCustomAnimations(
                R.anim.slide_in_up,
                R.anim.slide_out_down,
                R.anim.slide_in_up,
                R.anim.slide_out_down
            )
            .add(R.id.feed_subcontents_frame_container, activity.searchFragment, "searchFragment")
            .addToBackStack("searchFragment").commit()

What happens is that that the fragment is launched successfully and with transition, but there are two issues.

  1. When clicking the back button no transition happens at all, and the fragment just disappears with no animation.
  2. When I click the button that launches the fragment again, the app crashes with that message.

Everything is working just fine when I don't use transactions. I just pop the back stack hen the back button is clicked and I can go back and forth between opening and closing the fragment forever. But as soon as I add this transactions it breaks.

I've seen this post and people suggest switching to appcompat : 1.1.0-beta01 or 1.0.2 but I actually already have been using both. I tried removing wither and running the app and it still crashes. What am I doing wrong? I am just trying to implement a simple slide_in & slide_out animations.

Slide in:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromYDelta="100%p"
            android:toYDelta="0%p"/>
</set>

slide out:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
            android:duration="@android:integer/config_mediumAnimTime"
            android:fromXDelta="0"
            android:toYDelta="-100%" />
</set>
Heterotopia answered 8/8, 2019 at 23:58 Comment(2)
Have you found a solution?Subdelirium
Dealing with the same issue. I've tried the suggestions in the thread you linked to no avail.Serf

© 2022 - 2024 — McMap. All rights reserved.