elastic / apm-agent-android

Elastic APM Android Agent
Apache License 2.0
20 stars 6 forks source link

Getting Fragment Navigation Crash #354

Open Biyane opened 1 week ago

Biyane commented 1 week ago

We use Navigation Component for navigation. It works fine. When we add APM, it gives an error

java.lang.IllegalArgumentException: The fragment "SomeFragment" is unknown to the FragmentNavigator. Please use the navigate() function to add fragments to the FragmentNavigator managed FragmentManager.

What am I missing?

LikeTheSalad commented 6 days ago

Hi @Biyane

I'm not aware of any issues with fragment navigation so far so I'll need more details to try and find the root cause. So if possible I'd like to get the following info:

Also, it'd be helpful to get the full stacktrace of the error if possible.

I'll be able to provide a better diagnosis and hopefully solve your issue once I can analyze that information.

Biyane commented 5 days ago

@LikeTheSalad thank you, for the quick response.

It crashes not in every fragment, but in some fragments.

LikeTheSalad commented 4 days ago

Thank you for all those details, @Biyane

I took some time to modify the agent's sample app to try and match the same versions that you shared (except for the Android Gradle plugin one, I'm guessing you meant 8.4?) but unfortunately no luck reproducing it.

Based on what you mentioned here:

It crashes not in every fragment, but in some fragments.

I was curious to know what could be the difference between those fragments. I tried adding the safeargs plugin to navigate from the first fragment to the second one by using the generated navigation actions, just to see if switching from ids to actions would trigger the error, though no luck.

Here's the place where I was focusing on during my tests. If you could identify what could I change there to try and trigger the error, or even better, if you happen to have an example project to reproduce this issue that I could take a look at, it would also help a lot.

Thank you for your patience.