- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在运行启用了 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();
}
在 getHttpClientBuilder()
方法中调用“build()”时发生异常。
我还在 AndroidManifest.xml 中分配了一个默认应用程序,它扩展了 MultiDexApplication
并且在 onCreate(Bundle bundle )
。
该问题仅发生在 Kitkat 中。任何想法为什么?我试过降级 Okhttp 库并将其升级到最新版本,但没有成功。
编辑:
从 Retroft 构建器中删除客户端不会改变任何内容。错误仍然显示。
最佳答案
OkHttp 3.13+ 需要 Android 5+
square/okhttp github页面提到最低要求是Android 5+
如@Jaeger 所述,@fancyjyl 与低于 Android 5 的版本一起使用,我们需要使用 OkHttp 3.12.x,但不建议使用它。
关于java - Okhttp.Builder 中的 ExceptionInInitializerError w/Multidex & Kitkat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55992760/
我在项目的不同领域遇到了以下异常。最糟糕的是我不知道它是什么......我的项目中没有 com.b.a.c.b 包。我尝试在网络上搜索,但仍然不明白是什么导致了此异常。 在从另一个 Activity
当我尝试单独运行 junit 测试时,出现此错误。当我尝试使用 Ant(它运行所有测试)运行它时,它运行良好。谁能告诉我可能的原因是什么? src 文件夹和 test 文件夹在同一层次结构中。我必须链
考虑以下类: sealed class Fruit(val id: String, val label: String) { object orange : Fruit("Citrus sinen
编译良好: static final Screen screen = Screen.getInstance(); static final InputListener listener = Input
我正在尝试读取 jar 包中的文件 (blip3.out)。我正在使用 getResourceAsStream 获取 url,然后尝试从中读取。我已经进行了多次尝试,并使用其他帖子中的解决方案,但仍然
我将一个项目导入到 eclipse 中并添加了依赖项(仅 oracle 驱动程序和 junit4)。但是当我尝试运行该项目时,我收到 ExceptionInInitializerError 。由于某种
当我尝试运行以下代码时,我收到 ExceptionInInitializerError 而不是空指针异常。为什么? static { String s= null; System.out.
我正在尝试使用 Class.forName 从我的对象调用方法,但出现 java.lang.ExceptionInInitializerError class MainClass(implicit v
我收到了ExceptionInInitializerError。我被告知“getException() 方法现在被称为原因,并且可以通过 Throwable.getCause() 方法以及前面提到的“
我是 Applet 编程新手,想要制作一个 Applet 放在网站上。那么我们开始吧。 这个项目的目标是,如果您单击该按钮,它将在浏览器顶部打开一个 JFrame。但在测试时,它给了我一个 java.
我使用 swing JFrame 作为我的应用程序的 MainFrame。我有一个按钮应该创建一个新窗口。但它会在初始化时崩溃,我不知道为什么。 public class Dialog { p
下面是我在运行服务器时从 netbeans IDE 得到的错误。正如错误所说 Uncompilable source code - Projects.ApplicationMenu is not ab
我正在使用兼容性类来构建用户代理字符串: public abstract class Compatibility { private static int sdkInt = 0; pr
编辑:已解决,但我不明白为什么 在 PokemonEnum 中我有这行 private PokemonEnum[ ] pokemon = PokemonEnum.values(); 我把它改为: pr
我正在尝试初始化 GL11,因为我在引用一个有 的方法时遇到了麻烦 GL11 gl 作为它的参数。我试图在我的渲染器类中初始化它,但它没有用,所以我认为它的初始化搞乱了渲染器并创建了一个新类来初始化。
我在一些论坛上搜索过,这似乎是一个常见问题。但是我找不到解决方案。我没有做任何疯狂的事情,所以发生这种情况似乎很奇怪。 @Override protected Scene onCreateScene(
我一定是在做一些非常愚蠢的事情,但是当我尝试在我的单例中实例化一个对象时,我得到了一个 ExceptionInInitializerError: class MySingleton { priva
请注意,我知道关于的规则 ExceptionInInitializerErrors 它说:任何静态 block 中抛出的异常被包装到ExceptionInInitializerError 然后抛出 E
我在尝试运行我的应用程序时意外遇到了 ExceptionInIntiialize 错误。我相信当用户点击快速聊天按钮时会提示错误。 10-09 18:27:08.450: E/AndroidRunti
当启动 JavaFX 应用程序(嵌入了 Swing 代码)作为 Webstart 时,会发生以下错误: java.lang.ExceptionInInitializerError at com
我是一名优秀的程序员,十分优秀!