ExceptionInitializerError in Okhttp.Builder w/ Multidex & Kitkat
我在运行启用了 Multidex 的 Kitkat 4.4.2 的 VM 上遇到异常。ExceptionInInitializerError
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)
我有以下库:
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'
我正在使用此代码创建改造连接
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.API_LINK)
.addConverterFactory(GsonConverterFactory.create())
.client(Utils.getHttpClientBuilder())
.build();
并使用此代码获取构建器的实例
public static OkHttpClient getHttpClientBuilder(){
return new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
}
在方法中调用“build()”时发生异常。getHttpClientBuilder()
我还在AndroidManifest中分配了一个默认应用程序.xml,它扩展并在.MultiDexApplication
MultiDex.install(this);
onCreate(Bundle bundle)
此问题仅发生在基特卡特。任何想法为什么?我尝试过降级Okhttp库并将其升级到最新版本,但没有成功。
编辑:
从 Retroft 构建器中删除客户端不会更改任何内容。错误仍然显示。