-
Notifications
You must be signed in to change notification settings - Fork 61
Fix Square.OkHttp3 5.0.0+ by creating separate okhttp-android package while maintaining legacy compatibility #1239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mattleibow <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are lots of errors:
<---
---> (Inner Exception #9) System.Exception:
No matching artifact config found for:
com.squareup.okhttp3:okhttp:4.12.0
to satisfy dependency of:
com.squareup.retrofit2:retrofit:3.0.0
Please add following json snippet to config.json:
{
"groupId": "com.squareup.okhttp3",
"artifactId": "okhttp",
"version": "4.12.0",
"nugetVersion": "CHECK PREFIX 4.12.0",
"nugetId": "CHECK NUGET ID",
"dependencyOnly": true/false
}
config.json
Outdated
{ | ||
"groupId": "com.squareup.okhttp3", | ||
"artifactId": "okhttp", | ||
"artifactId": "okhttp-android", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this a new package, and move the relevant Metadata.xml
and Additions/*.cs
to be used in the new package?
Keep the existing okhttp
package, and it shouldn't need Metadata.xml
or Additions/*.cs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Created a new package approach:
- okhttp (4.12.0): Kept for dependencies, removed customizations, marked as
dependencyOnly: true
- okhttp-android (5.1.0): New package
Square.OkHttp3.Android
with all existingMetadata.xml
and binding customizations moved tosource/com.squareup.okhttp3/okhttp-android/
This maintains compatibility with existing consumers while providing the correct Android implementation. Commit: dc5482d
…ncies Co-authored-by: jonathanpeppers <[email protected]>
... Fixed the dependency resolution error by creating separate packages:
This ensures all dependencies resolve while providing the correct Android implementation in a separate NuGet package. Commit: dc5482d |
config.json
Outdated
"version": "4.12.0", | ||
"nugetVersion": "4.12.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot shouldn't this be 5.1.0
version? You are downgrading this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! Updated the okhttp version from 4.12.0 to 5.1.0 to match the okhttp-android version. Both packages now use version 5.1.0 consistently. Commit: 986e6a4
Co-authored-by: jonathanpeppers <[email protected]>
From OkHttp version 5.0.0+, Square changed their packaging strategy to provide separate JVM and Android artifacts. The regular
com.squareup.okhttp3:okhttp
artifact is now just an empty placeholder for Android (containing only 767 bytes of metadata), while the actual Android implementation has been moved tocom.squareup.okhttp3:okhttp-android
.This change caused the generated Square.OkHttp3 NuGet packages version 5.0.0+ to be empty, as they were binding the placeholder JAR instead of the real Android implementation.
However, other packages (like Retrofit 3.0.0) still depend on the legacy
okhttp
artifact, so simply switching artifacts would break dependency resolution.Solution
This PR implements a dual-package approach:
Legacy compatibility package:
com.squareup.okhttp3:okhttp:4.12.0
dependencyOnly: true
to satisfy existing dependenciesSquare.OkHttp3
(maintains existing package ID)New Android implementation package:
com.squareup.okhttp3:okhttp-android:5.1.0
source/com.squareup.okhttp3/okhttp-android/
Square.OkHttp3.Android
(new package ID)Changes Made
okhttp
(legacy) andokhttp-android
(new implementation)source/com.squareup.okhttp3/okhttp-android/
with existingMetadata.xml
and customizationsokhttp
dependencies while new consumers get the full Android implementationThis approach ensures backward compatibility while providing access to the correct OkHttp Android functionality.
Fixes #1230.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.