Android - NewRelic/Retrofit - 每个请求都有 okhttp 错误

Android - NewRelic/Retrofit - bug with okhttp on every request

我使用 New Relict com.newrelic.agent.android:android-agent:5.1.0, 5.1.1 or 5.0.0 和 retrofit 1.9 得到这个异常!我在哪里可以报告新遗物中的错误?有人有同样的问题吗?

java.lang.IllegalAccessError: Method 'void com.squareup.okhttp.Call.(com.squareup.okhttp.OkHttpClient, com.squareup.okhttp.Request)' is inaccessible to class 'com.newrelic.agent.android.instrumentation.okhttp2.CallExtension' (declaration of 'com.newrelic.agent.android.instrumentation.okhttp2.CallExtension' appears in /data/app/com.thepickupnetwork.customer.app-2/base.apk)
at com.newrelic.agent.android.instrumentation.okhttp2.CallExtension.(CallExtension.java:32)
at com.newrelic.agent.android.instrumentation.okhttp2.OkHttp2Instrumentation.newCall(OkHttp2Instrumentation.java:28)
at retrofit.client.OkClient.execute(OkClient.java:53)
at com.newrelic.agent.android.instrumentation.retrofit.ClientExtension.execute(ClientExtension.java:42)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access0(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)

我运行陷入同样的​​问题。基本上我的解决方案是将 okhttp 从版本 2.4.0 降级到 2.2.0。它看起来像是新遗物库中的错误。看这里:https://github.com/square/okhttp/issues/1680

2.4 中 OkHttp Call 构造函数范围的更改破坏了我们的检测。对此的修复已合并到 OkHttp 中,并将在 2.5 版中修复:https://github.com/square/okhttp/pull/1687

同时,两种解决方法是使用 OkHttp 2.3 或使用 Sonatype 快照存储库中的 2.5.0-SNAPSHOT,如下所示:

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ....
    compile 'com.squareup.okhttp:okhttp:2.5.0-SNAPSHOT'
    ....

来源:https://discuss.newrelic.com/t/bug-with-okhttp/25893