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

那年仲夏 提交于 2019-12-20 21:01:48

问题


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:

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


回答1:


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.



来源:https://stackoverflow.com/questions/26747828/could-not-find-class-android-transition-transition-exception-when-pressing-bac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!