sdk-for-android icon indicating copy to clipboard operation
sdk-for-android copied to clipboard

Bug Report: Incompatibility with OkHttp 5.x – NoClassDefFoundError: okhttp3.internal.Util

Open midou221 opened this issue 5 months ago • 3 comments

👟 Reproduction steps

  1. Add implementation("com.squareup.okhttp3:okhttp:5.1.0") to dependencies
  2. Use Appwrite SDK in your Android app
  3. Run a request that uses cookies
  4. Crash occurs at ListenableCookieJar

👍 Expected behavior

  • The Appwrite SDK should not rely on internal or private OkHttp classes.
  • ListenableCookieJar should use only public APIs (e.g. java.net.HttpCookie.parse(...)) to handle cookies.
  • App should work normally without crashing when using OkHttp 5.x.

👎 Actual Behavior

  • App crashes at runtime with the following error:
  • Caused by internal API usage that was removed in OkHttp 5.1.0.
  • Makes it impossible to use Appwrite SDK with the latest OkHttp versions.

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Something else

🧱 Your Environment

  • Appwrite SDK version: 8.1.0
  • OkHttp version: 5.1.0
  • Android version: Any
  • Crash location: ListenableCookieJar.kt

👀 Have you spent some time to check if this issue has been raised before?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

midou221 avatar Jul 12 '25 10:07 midou221

@midou221 hi there, thanks for raising this issue. can you please share the full stack trace of the error so we can pinpoint which internally removed API is being used by the appwrite sdk?

ChiragAgg5k avatar Jul 14 '25 05:07 ChiragAgg5k

i am not able to find anything particular in the changelog

Image

https://square.github.io/okhttp/changelogs/changelog/

ChiragAgg5k avatar Jul 14 '25 05:07 ChiragAgg5k

@midou221 hi there, thanks for raising this issue. can you please share the full stack trace of the error so we can pinpoint which internally removed API is being used by the appwrite sdk?

Here’s the full stack trace

Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Util" on path: DexPathList[[zip file "/data/app/org.example-Ro1f0UMkG_IWRQNxsaF_cA==/base.apk"],nativeLibraryDirectories=[/data/app/org.example-Ro1f0UMkG_IWRQNxsaF_cA==/lib/arm64, /data/app/org.example-Ro1f0UMkG_IWRQNxsaF_cA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at io.appwrite.cookies.ListenableCookieJar.decodeHeaderAsJavaNetCookies(ListenableCookieJar.kt:88)  at io.appwrite.cookies.ListenableCookieJar.loadForRequest(ListenableCookieJar.kt:66)  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:75)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126)  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:126)  at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:208)  at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:530)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)  at java.lang.Thread.run(Thread.java:784) 

The crash is triggered because the Appwrite SDK still references okhttp3.internal.Util, which was removed in OkHttp 5.x.

midou221 avatar Jul 14 '25 05:07 midou221