Retrofit: java.lang.NoClassDefFoundError: java.util.Objects

Created on 3 Mar 2019  Â·  7Comments  Â·  Source: square/retrofit

this error throw when using retrofit version 2.5.0 in android lower than api 19

java.lang.NoClassDefFoundError: java.util.Objects at okhttp3.CertificatePinner.withCertificateChainCleaner(CertificatePinner.java:231) at okhttp3.OkHttpClient.<init>(OkHttpClient.java:271) at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1054)

Most helpful comment

This is a problem with OkHttp, not Retrofit. Note OkHttp 3.13+ requires API 21+ but if you're using 3.12 or earlier please file a bug.

All 7 comments

This is a problem with OkHttp, not Retrofit. Note OkHttp 3.13+ requires API 21+ but if you're using 3.12 or earlier please file a bug.

ok, when retrofit depend on okhttp how to fix it for api level lower than 19?
@JakeWharton

Retrofit doesn't require nor depend on 3.13 so it isn't forcing minSdk 21

On Mon, Mar 4, 2019 at 2:45 AM Milad Heydari notifications@github.com
wrote:

ok, when retrofit depend on okhttp how to fix it for api level lower than
19?

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/3042#issuecomment-469150305,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEESPP2TNoaM7RFrGkzBWAFciL1e45ks5vTM8OgaJpZM4bbB_s
.

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: java.util.Objects
at okhttp3.CertificatePinner.withCertificateChainCleaner(CertificatePinner.java:231)
at okhttp3.OkHttpClient.(OkHttpClient.java:238)
at okhttp3.OkHttpClient.(OkHttpClient.java:202)

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: java.util.Objects
at okhttp3.CertificatePinner.withCertificateChainCleaner(CertificatePinner.java:231)
at okhttp3.OkHttpClient.(OkHttpClient.java:238)
at okhttp3.OkHttpClient.(OkHttpClient.java:202)

@JakeWharton

ok, when retrofit depend on okhttp how to fix it for api level lower than 19?
@JakeWharton

is your problem solved?
i have the same problem just in release apk and my okhhtp version is lower than 3.12.

From Retrofit's changelog, from Retrofit 2.7.0 depends on OkHttp 3.14.4 that changes minimum requirements to Android 5 or later.

To support min SDK version 16, use Retrofit 2.6.4 and make sure OkHttp version 3.12.x (see this)

Was this page helpful?
0 / 5 - 0 ratings