fix: [SDK-4160] exclude OkHttp 5.x from otel module transitive dependencies#2577
Closed
fadi-george wants to merge 2 commits into
Closed
Conversation
…encies The otel module's opentelemetry-exporter-otlp transitively pulls in okhttp-jvm 5.x via opentelemetry-exporter-sender-okhttp. OkHttp 5.x is binary-incompatible with consumers that depend on OkHttp 4.x (e.g. React Native's networking stack references okhttp3.internal.Util which was removed in 5.x), causing NoClassDefFoundError crashes at runtime. Exclude the com.squareup.okhttp3 group from the OTLP exporter and explicitly provide okhttp 4.12.0 instead. Fixes #2575 Made-with: Cursor
fadi-george
added a commit
to OneSignal/react-native-onesignal
that referenced
this pull request
Mar 17, 2026
The OkHttp 5.x incompatibility is being fixed in the Android SDK's otel module (OneSignal/OneSignal-Android-SDK#2577). Remove the workaround from this wrapper since resolutionStrategy.force in a library's build.gradle does not propagate to the consuming app's resolution. Made-with: Cursor
fixes issue when logging it when anonymous
abdulraqeeb33
approved these changes
Mar 17, 2026
| implementation('io.opentelemetry:opentelemetry-exporter-otlp') { | ||
| exclude group: 'com.squareup.okhttp3' | ||
| } | ||
| implementation 'com.squareup.okhttp3:okhttp:4.12.0' |
Contributor
There was a problem hiding this comment.
can you please move the version number out in the root project?
14 tasks
Contributor
Author
|
I think I want to go with RN side fix for now @abdulraqeeb33 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Exclude OkHttp 5.x transitive dependency from the otel module to prevent runtime crashes in consumers using OkHttp 4.x.
Details
Motivation
The
otelmodule (added in 5.7.0) depends onopentelemetry-exporter-otlp, which transitively pulls inokhttp-jvm:5.2.1viaopentelemetry-exporter-sender-okhttp. OkHttp 5.x is binary-incompatible with OkHttp 4.x — specifically,okhttp3.internal.Utilwas removed in 5.x.When a consumer (e.g. a React Native app) also depends on OkHttp 4.x, Gradle's conflict resolution upgrades everything to 5.2.1 (since OkHttp 5.x's module metadata declares
okhttp-jvmreplacesokhttp). This causes aNoClassDefFoundError: okhttp3/internal/Utilcrash at runtime when React Native's networking stack (ReactCookieJarContainer→JavaNetCookieJar) handles cookies.Dependency chain:
Scope
com.squareup.okhttp3group fromopentelemetry-exporter-otlptransitive dependenciescom.squareup.okhttp3:okhttp:4.12.0(latest stable 4.x)Fixes #2575
Testing
Unit testing
All existing otel module unit tests pass (
./gradlew :OneSignal:otel:testReleaseUnitTest).Manual testing
Verified via
./gradlew :OneSignal:otel:dependencies --configuration releaseRuntimeClasspaththatokhttp-jvm:5.2.1no longer appears in the dependency tree andokhttp:4.12.0is resolved instead.Tested crash logs

Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor