java.lang.NoSuchMethodError: No virtual method names()Ljava/util/Set; in class Lokhttp3/Headers
See original GitHub issueHi guys,
I’m using retrofit (2.4.0) and OkHttp Interceptor (3.10.0) in an Android project and I’m facing a crash on a request.
I’m using Proguard to optimize and shrink the code.
java.lang.NoSuchMethodError: No virtual method names()Ljava/util/Set; in class Lokhttp3/Headers; or its super classes (declaration of 'okhttp3.Headers' appears in /data/app/package==/base.apk)
at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.toMultimap(OkHttp3Interceptor.java:102)
at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.trackRequest(OkHttp3Interceptor.java:71)
at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:42)
at io.reactivex.Observable.subscribe(Observable.java:11194)
at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
at io.reactivex.Observable.subscribe(Observable.java:11194)
at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
at io.reactivex.Single.subscribe(Single.java:3096)
at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:84)
at io.reactivex.internal.operators.single.SingleCreate$Emitter.onSuccess(SingleCreate.java:68)
at package.AphaelService$Factory$create$1.subscribe(MyRetrofitService.kt:226)
I was able to get rid of this issue adding this Proguard line to my configuration :
-keep class okhttp3.Headers { *; }
I checked the versions of both retrofit and OkHttp and they are matching each other (compatible).
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
java.lang.NoSuchMethodError: No virtual method toString(Z ...
You're pulling in an old version of okhttp-urlconnection, and it is incompatible with the current version of the OkHttp core library.
Read more >Seemingly random "NoSuchMethodError: No virtual method"
I have absolutely no idea what it is that triggers it though, so creating a repro seems impossible. Stack trace is below. These...
Read more >java.lang.NoSuchMethodError: No virtual method build()Lcom ...
NoSuchMethodError : No virtual method build()Lcom/google/android/exoplayer2/DefaultLoadControl. I have created a Binding Library for Triton ...
Read more >No virtual method load(Ljava/lang/String;)Lcom/squareup ...
Hello, I am using picasso library (link) for my imageview in my customlistview and it is working great. I am also using in...
Read more >java.lang.NoSuchMethodError No virtual method log(ILjava ...
NoSuchMethodError : No virtual method log(ILjava/lang/String;Ljava/lang/Throwable;)V in class Lokhttp3/internal/platform/Platform; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This isn’t a bug in OkHttp. ProGuard is removing that method and then the Android Studio network profiler code that is injected into your APK is assuming the method will be present. You should file a bug at https://issuetracker.google.com/issues/new?component=317727 that the network profiler needs to either bundle ProGuard rules for the methods they require or put their API onto the ProGuard classpath so anything it uses is automatically retained.
The right answer would be “deactivate Android Studio profiling” since it’s the advanced profiler that injects these classes at runtime.
Go to “Edit configuration” on your gradle task that launch the app, then from the “Profiling” tab uncheck the “Enable advanced profiling” entry.
Of course this is an Android Studio bug that you can track here