My App is crashing on Android 11 with: java.lang.ExceptionInInitializerError at okhttp3.OkHttpClient

Viewed 2560

My App is crashing on Android 11 with the following log:

2021-01-01 18:16:52.556 10648-10648/com.myapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.myapp, PID: 10648
    java.lang.ExceptionInInitializerError
        at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:211)
        at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:204)
        at retrofit2.Retrofit$Builder.build(Retrofit.java:628)
        at com.myapp.MyApplication.onCreate
1 Answers

In my case I was using:

implementation 'com.squareup.okhttp3:logging-interceptor:4.0.1'

Updating okHttp to version 4.4.0 fixes the problem.

implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0'
Related