Skip to content

Relax fragment dependency#941

Closed
breedx-splk wants to merge 1 commit into
open-telemetry:mainfrom
breedx-splk:change_fragment_deps
Closed

Relax fragment dependency#941
breedx-splk wants to merge 1 commit into
open-telemetry:mainfrom
breedx-splk:change_fragment_deps

Conversation

@breedx-splk
Copy link
Copy Markdown
Contributor

This changes the dependency on navigation-fragment to compileOnly for all modules except fragment intsrumentation.

This should prevent a transitive dependency for users who do not use fragments, and doesn't force a newer version on users who might use an older version.

I tried the demo app, and it came up just fine. I believe that this is because the demo-app uses the agent, and the agent includes fragment instrumentation, so it picks up the transitive dependency as normal. It's a little worrying to have references to Fragment classes with a mere compileOnly(), so we should figure out what our end state should look like.

@marandaneto
Copy link
Copy Markdown
Member

I think the only problem is if any classes that depend on the fragment lib try to be loaded/instantiated.
is that the case?
if so, we'd need to do reflection and check if the fragment lib is available at runtime before doing so:
eg

val clazz = "androidx.fragment.app.FragmentManager$FragmentLifecycleCallbacks"
val isFragmentAvailable = try Class.forName(clazz) catch ...
if (!isFragmentAvailable) return
// import and use android fragment classes

otherwise the app will crash at runtime

@bidetofevil
Copy link
Copy Markdown
Contributor

Feels like some instrumentation, especially ones with special deps, should be pulled into its own module and can thus be not included for folks who don't want it.

@bidetofevil
Copy link
Copy Markdown
Contributor

What remains of this should be handled in #961

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants