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

832 views Asked by At

I get this exeption using New Relict com.newrelic.agent.android:android-agent:5.1.0, 5.1.1 or 5.0.0 and retrogit 1.9! Where can I report a bug in new relic? anyone with the same issue?

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.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.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$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)
2

There are 2 answers

0
Daniel Gomez Rico On BEST ANSWER

A change in the scope of the OkHttp Call constructor in 2.4 breaks our instrumentation. A fix for this has been merged into OkHttp and will be fixed in release 2.5: https://github.com/square/okhttp/pull/1687

In the mean time, the two workarounds are to either use OkHttp 2.3 or use 2.5.0-SNAPSHOT from the Sonatype snapshot repo, like so:

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'
    ....

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

1
lutchobandeira On

I ran into the same problem. Basically the solution for me was to downgrade okhttp from version 2.4.0 to 2.2.0. It looks like a bug in the new relic lib. Take a look here: https://github.com/square/okhttp/issues/1680