Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not find class android.transition.Transition" exception when pressing back button

I have one activity that hosts one fragment at a time, and swaps between two fragments. Fragment A starts Fragment B using a button, and Fragment B starts fragment A either using a button or the back button.

Everything works fine when going from Fragment A to B and from B to A using the custom buttons. The problem is when I use the back button to go from Fragment B to A (Fragment A adds the transaction to the back stack).

When pressing the back button while on Fragment B, I get several "Could not find class android.transition.Transition" exceptions and "Unable to resolve check-cast 1217 warnings, like 11 of each, which don't crash the program:

Log

I have no idea what this means, or how this can be solved.

This is how Fragment A starts Fragment B:

mButtonNextFragment.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        FragmentManager fm = getActivity().getSupportFragmentManager();
        Fragment fragment = FragmentTwo.newInstance(mCount);
        fragment.setTargetFragment(FragmentOne.this, 0);

        fm.beginTransaction()
            .addToBackStack("transaction1")
            .replace(R.id.layout_fragmentContainer, fragment)
            .commit();
    }
});

This is how Fragment B starts Fragment A:

mButtonPrevFragment.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        FragmentManager fm = getActivity().getSupportFragmentManager();
        fm.beginTransaction()
            .replace(R.id.layout_fragmentContainer, getTargetFragment())
            .commit();
    }
});

And this is how the host activity starts Fragment A:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment_container);

    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.layout_fragmentContainer);

    if (fragment == null) {
        fragment = new FragmentOne();
        fm.beginTransaction()
            .add(R.id.layout_fragmentContainer, fragment)
            .commit();
    }
}

Anyone knows the cause of this problem?

Here is the complete error log: http://pastebin.com/CPtCUBYg

like image 569
runw Avatar asked Nov 05 '14 00:11

runw


1 Answers

Kinda late, but I may have something. Not sure what's the cause of this problem, I`ll make some research later, but here in my Project happened the same error after I updated the android-support lib. Using an older version (that was inside HoloEverywhere library) worked normally. Try using an older version of android-support to see if works better. Maybe something went deprecated in a recent version, but I'm not sure.

like image 144
Viniciusoh Avatar answered Sep 22 '22 04:09

Viniciusoh