情況概述
對一個(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包的,如下:

讓人納悶,之前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)哦。