相关文章推荐
逃跑的面包  ·  fabric.js ...·  1 年前    · 
八块腹肌的啤酒  ·  java - How to set TLS ...·  1 年前    · 

错误:'E/AndroidRuntime。FATAL EXCEPTION: OkHttp Dispatcher' in using react native

6 人关注
2020-12-01 11:20:24.357 16113-16534/com.innerfit.app E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.innerfit.app, PID: 16113
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:2064)
        at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.kt:98)
        at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.kt:59)
        at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.java:44)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:75)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)

Axios请求在几个请求中工作正常,但这一崩溃发生后,就没有什么工作了。不得不删除应用程序并重新安装,以使其再次工作。

Things I tried:

  • Added { 'Connection': 'close' } in all requests according to this GitHub issue but doesn't fix it. https://github.com/facebook/react-native/issues/11016#issuecomment-336685459
  • Added okhttp3 dependencies in Gradle file. https://github.com/facebook/react-native/issues/27250#issuecomment-573111088
  •  dependencies {
         compile "com.squareup.okhttp3:okhttp:4.2.1"
         compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
         compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
        
    android
    react-native
    sourabh dadapure
    sourabh dadapure
    发布于 2020-12-02
    1 个回答
    Altynbek Usenbekov
    Altynbek Usenbekov
    发布于 2021-10-29
    已采纳
    0 人赞同

    我认为这与这个问题有关。 https://github.com/square/okhttp/issues/6897

    okhttp_4.2.x -> JavaNetCookieJar.kt ( https://github.com/square/okhttp/blob/okhttp_4.2.x/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.kt ) Line: 98

    if (value.startsWith("\"") && value.endsWith("\"")) {