fix(android): declare okhttp-android runtime dep and add CTEntry.imageURL [NT-3807] - #406
Merged
Merged
Conversation
…eURL [NT-3807] Consumers of the Android SDK hit `ClassNotFoundException: okhttp3.OkHttpClient` at launch because contentful.java transitively bumps okhttp to 5.1.0 (whose parent module is KMP metadata only) with `okhttp-jvm` excluded — leaving no concrete okhttp variant on the runtime classpath. Declare `com.squareup.okhttp3:okhttp-android:5.1.0` directly so it lands there. Version-aligning to okhttp-android 5.x also removes the duplicate-class packaging failure consumers were hitting from a mixed 4.x/5.x classpath, so the reference implementation apps no longer need `packaging.resources.excludes` workarounds. Update the ref-impl `shared` and `compose` modules to the same `okhttp-android:5.1.0` artifact. Add `CTEntry.imageURL: String?` extension property that resolves the linked asset URL and prepends `https:` to protocol-relative Contentful Asset URLs (Android image loaders reject the scheme-less form). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Charles Hudson (phobetron)
approved these changes
Aug 3, 2026
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.
Follow-up to #395.
Summary
com.squareup.okhttp3:okhttp-android:5.1.0directly inpackages/android/ContentfulOptimization/build.gradle.kts. The prior PR setcontentful.javatocompileOnlywithokhttp-jvmexcluded to avoid a duplicate-class conflict, but the transitive bump left the parentokhttp:5.x(KMP metadata only) on the graph — consumers crashed at launch withClassNotFoundException: okhttp3.OkHttpClienton the first line that touched the SDK.implementations/android-sdk/sharedandimplementations/android-sdk/composefromokhttp:4.12.0tookhttp-android:5.1.0. With both variants aligned on 5.x, the ref-impl no longer hits the duplicate-class packaging failure and no consumer-sidepackaging.resources.excludesworkaround is needed. Verified:compose:assembleDebugand:views:assembleDebugbothBUILD SUCCESSFULwithout any excludes.CTEntry.imageURL: String?extension property. Reads the linked-asset URL from a Contentfulimagefield and prependshttps:to protocol-relative//images.ctfassets.net/...URLs so Android image loaders (Coil/Glide) can consume it.okhttp-android:5.xfor alignment. Internal SDK knowledge base updated with the runtime-dep fact and the new extension property.Test plan
pnpm android:test— BUILD SUCCESSFUL, 3 newCTEntry.imageURLunit tests pass (protocol-relative rewrite, absolute URL passthrough, null-safe missing fields).pnpm lint— clean.pnpm format:check— clean../gradlew :compose:assembleDebug(Android reference impl) — BUILD SUCCESSFUL without any packaging excludes../gradlew :views:assembleDebug(Android reference impl) — BUILD SUCCESSFUL without any packaging excludes.implementation("com.contentful.java:optimization-android:<version>")(nookhttp-androidoverride, no packaging excludes) and confirmMainActivitylaunches withoutClassNotFoundException.🤖 Generated with Claude Code