I'm experiencing an ExceptionInInitializerError exception on VM running Kitkat 4.4.2 with Multidex enabled.
java.lang.ExceptionInInitializerError
at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263)
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229)
at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015)
at myapp.utils.Utils.getHttpClientBuilder(Utils.java:131)
at myapp.fragments.FragmentHome.getHome(FragmentHome.java:326)
at
myapp.fragments.FragmentHome.onViewCreated(FragmentHome.java:135)
I have the following libraries:
implementation 'jp.wasabeef:recyclerview-animators:3.0.0'
implementation 'com.ashokvarma.android:bottom-navigation-bar:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:2.0.0@aar'
implementation 'com.duolingo.open:rtl-viewpager:1.0.3'
implementation 'com.squareup.retrofit2:retrofit-converters:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.1'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'saschpe.android:customtabs:2.0.0'
I'm creating a retrofit connection using this code
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.API_LINK)
.addConverterFactory(GsonConverterFactory.create())
.client(Utils.getHttpClientBuilder())
.build();
And getting an instance of the builder using this code
public static OkHttpClient getHttpClientBuilder(){
return new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
}
The exception happens when calling "build()" in the getHttpClientBuilder() method.
I also have a default application assigned in the AndroidManifest.xml, it extends MultiDexApplication and has MultiDex.install(this); in onCreate(Bundle bundle).
The issue only happens in Kitkat. Any ideas why? I've tried downgrading Okhttp library and upgrading it to the latest version, it didn't work out.
from ExceptionInInitializerError in Okhttp.Builder w/ Multidex & Kitkat
No comments:
Post a Comment