sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Package OkHttp as a jar instead of aar

Open bruno-garcia opened this issue 3 years ago • 7 comments

In order to use our OkHttp library with Jetpack Compose on desktop, it must be packaged as a jar since it runs on the JVM.

Additionally we could deprecate sentry-android-okhttp in favor of sentry-okhttp if it doesn't have any Android specific dependency.

bruno-garcia avatar Oct 26 '21 14:10 bruno-garcia

if we want to ship the proguard-rules.pro for okhttp within our integration, it should be an aar, but we can move the SentryOkHttpInterceptor class to a jar file and just ship the jar as a transitive dependency of the aar (its a breaking change tho)

marandaneto avatar Oct 27 '21 08:10 marandaneto

Perhaps something for 6.0?

maciejwalkowiak avatar Oct 27 '21 08:10 maciejwalkowiak

I have a feeling that with some Gradle magic we can actually publish both .aar with proguard rules and .jar without them from a single module, avoiding any breaking changes. Can look into this later

romtsn avatar Oct 27 '21 11:10 romtsn

Java users would still need to import io.sentry.android.okhttp.SentryOkHttpInterceptor which is weird, well, its just a package name, since we are cooking v6, it'd be fine.

marandaneto avatar Oct 27 '21 11:10 marandaneto

It is not necessary to distribute as an aar to package proguard rules. Moshi is distributed as a jar and packages proguard rules. I'm not sure if that works with legacy proguard, but it does work with R8.

If you extract this jar you can see that you can bundle them using normal java resources. https://repo1.maven.org/maven2/com/squareup/moshi/moshi/1.12.0/moshi-1.12.0.jar

remcomokveld avatar Oct 29 '21 10:10 remcomokveld

indeed @remcomokveld thanks for pointing this out. AGP is responsible for merging the proguard rules from aar/jar files before proguard/r8 runs, so it's more about a back-compatibility with older AGP versions. if we find out from which version this started being possible, we can also point out on docs and go with jar only.

marandaneto avatar Oct 29 '21 11:10 marandaneto

Raised the priority to p2 here since our Kotlin Multiplatform SDK is moving forward with JVM support and we could unblock @remcomokveld and other folks who want to take advantage of this. Also it's a low effort.

bruno-garcia avatar Aug 05 '22 15:08 bruno-garcia

If needed, we can have a sentry-okhttp and sentry-android-okhttp so people don't have to change their dependencies. Maybe imports will be broken still, but its more straightforward to fix.

marandaneto avatar May 22 '23 07:05 marandaneto

Closed by #3005

romtsn avatar Nov 24 '23 13:11 romtsn