1

The Stacktrace I got in crashlytics fabric is as follows,

Fatal Exception: java.lang.IllegalStateException: No activity
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1058)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
   at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1862)
   at android.app.Fragment.performActivityCreated(Fragment.java:1724)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1071)
   at android.app.BackStackRecord.run(BackStackRecord.java:684)
   at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1456)
   at android.app.FragmentManagerImpl$1.run(FragmentManager.java:444)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5398)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
   at dalvik.system.NativeStart.main(NativeStart.java)
Show all 74 Threads

I am not finding it helpful in any way. Can anybody tell me how can I trace it and how to find which activity is causing problem and what may be the problem?

3
  • 1
    Well, not enough information to comment, you just displayed an error stack trace... what Fragment is involved with this error, when does it occur? Are you pressing the back button by any chance when this occurs? Commented Sep 11, 2017 at 13:42
  • stackoverflow.com/questions/34207353/… stackoverflow.com/questions/15784155/… stackoverflow.com/questions/14929907/… You gotta try a little bit Commented Sep 11, 2017 at 13:43
  • This stacktrace I got from crashlytics, and its all what crashlytics provided, I have no Idea where it caused as the project is pretty big Commented Sep 11, 2017 at 13:48

1 Answer 1

2

You are using wrong FragmentManager to nest the fragments. You should use fragmentManager instance returned by

getChildFragmentManager();  

instead of using

getSupportFragmentManager();

You can get more information about nested fragments here : https://developer.android.com/about/versions/android-4.2.html#NestedFragments

You can embed fragments inside fragments. This is useful for a variety of situations in which you want to place dynamic and re-usable UI components into a UI component that is itself dynamic and re-usable. You can insert fragments into each fragment page.

To nest a fragment, simply call getChildFragmentManager() on the Fragment in which you want to add a fragment. This returns a FragmentManager that you can use like you normally do from the top-level activity to create fragment transactions. For example, here’s some code that adds a fragment from within an existing Fragment class:

Fragment videoFragment = new VideoPlayerFragment();
FragmentTransaction transaction = 
      getChildFragmentManager().beginTransaction();
    transaction.add(R.id.video_fragment, videoFragment).commit();

From within a nested fragment, you can get a reference to the parent fragment by calling getParentFragment().

Sign up to request clarification or add additional context in comments.

6 Comments

Any way I can trace which fragment is the criminal here?
first you need to see the usage of getSupportFragmentManager(); in you code. can you please post your code?
There are 20+ fragments
any other way to find out, I am experiencing plenty of crashes in crashlytics due to this
Instances where you have nested fragments? i.e. created fragments inside fragment?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.