java.lang.NoSuchMethodError: No virtual method startsWith(Lokio/ByteString;)Z in class Lokio/Byte...

情況概述

對一個(gè)項(xiàng)目進(jìn)行埋點(diǎn)操作,在埋點(diǎn)之前沒有任何問題,但是埋點(diǎn)之后發(fā)現(xiàn)程序直接奔潰

報(bào)錯(cuò)堆棧信息:

java.lang.NoSuchMethodError: No virtual method startsWith(Lokio/ByteString;)Z in class Lokio/ByteString; or its super classes (declaration of 'okio.ByteString' appears in /data/app/包名/split_lib_dependencies_apk.apk)
at okhttp3.internal.http2.Hpack$Writer.writeHeaders(Hpack.java:511)
at okhttp3.internal.http2.Http2Writer.headers(Http2Writer.java:299)
at okhttp3.internal.http2.Http2Writer.synStream(Http2Writer.java:127)
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:230)
at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:205)
at okhttp3.internal.http2.Http2Codec.writeRequestHeaders(Http2Codec.java:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:46)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)等等

解決問題

查看錯(cuò)誤,大概意思就是找不到類Lokio/ByteString,或者它的父類, 'okio.ByteString'聲明的問題,主要堆棧來源于okhttp3,小豆嘗試全局搜索Lokio類,未曾使用過,搜索ByteString類,使用到了但是發(fā)現(xiàn)未被導(dǎo)入,找不到關(guān)于okhttp包,但是著實(shí)是添加了okhttp jar包的,如下:


jar包.png

讓人納悶,之前app也沒有任何問題,集成用于埋點(diǎn)的第三方sdk后,出現(xiàn)了找不到okhttp的問題,于是聽從朋友建議,將添加jar包的方式在對應(yīng)模塊中換成依賴方式,如下:

compile 'com.squareup.okhttp:okhttp:2.7.0'
compile 'com.squareup.okio:okio:1.10.0'

完美解決??!

總結(jié)

查閱資料時(shí),看到網(wǎng)上有朋友寫到:

Java.lang.NoSuchMethodError: 后帶 V/Z等字母的 錯(cuò)誤,一般都是 jar包沖突引起的

現(xiàn)在想想,可能埋點(diǎn)第三方也存在這個(gè)jar包吧,才導(dǎo)致沖突的。
解決問題參考鏈接:
https://blog.csdn.net/qq_37299249/article/details/73149512
https://blog.csdn.net/zhaipengfei1231/article/details/78200869
其他朋友有更好的想法,請幫小豆多多指導(dǎo)哦。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容