阿里一鍵登錄java.lang.NoSuchMethodError: no non-static method “Lcom/mobile/auth/gatewayauth/model/RStruct;

先說結(jié)果,加入下列混淆:

-keep class org.json.** {
   *;
}

記錄下排除步驟

在集成阿里云登錄的時候,不混淆的情況不會出現(xiàn),但開啟混淆后就報下面代碼

java.lang.NoSuchMethodError: no non-static method "Lcom/mobile/auth/gatewayauth/model/RStruct;.toJson()Lorg/json/JSONObject;" at com.mobile.auth.gatewayauth.utils.EncryptUtils.encryptToken(Native Method) at com.mobile.auth.gatewayauth.utils.TokenGenerator.assembleToken(Native Method) at com.mobile.auth.gatewayauth.utils.TokenGenerator.a(Unknown Source:21) at com.mobile.auth.gatewayauth.manager.TokenMaskManager.a(Native Method) at com.mobile.auth.gatewayauth.manager.TokenMaskManager.a(Unknown Source:0) at com.mobile.auth.gatewayauth.manager.TokenMaskManager$11.a(Unknown Source:36) at com.mobile.auth.gatewayauth.manager.TokenMaskManager$11.a(Unknown Source:2) at com.mobile.auth.ak.d.a(Unknown Source:140) at com.mobile.auth.ak.d$b.run(Unknown Source:27) at java.util.concu 2021-05-13 18:25:05.186 4749-5857/com.

首先想到的是 會不會是一鍵登錄混淆代碼沒加?

然而在查看官方文檔發(fā)現(xiàn)無需添加,查看了下阿里云的arr包發(fā)現(xiàn)確實添加了混淆代碼

官方文檔

各種嘗試無果后覺得還是得反編譯看下,由于代碼提示

"Lcom/mobile/auth/gatewayauth/model/RStruct;.toJson()Lorg/json/JSONObject;"
at com.mobile.auth.gatewayauth.utils.EncryptUtils.encryptToken(Native Method)

首先是擔(dān)心是native方法給混淆了(其實想想提示也不會是native方法),就找到EncryptUtils類看下反編譯代碼,發(fā)現(xiàn)沒啥問題


在這里插入圖片描述

然后查看RStruct類 發(fā)現(xiàn)了問題點(diǎn)

在這里插入圖片描述

aar源碼
在這里插入圖片描述

其中有個JSONObject給混淆了,然后回想起jni中,c層調(diào)java層代碼不單止要指定類路徑 還要指定方法的參數(shù)和返回值否則回找不到
由于返回類型給混淆到了所以會提示找不到非靜態(tài)的toJson方法

解決方法就是不混淆org.json.JSONObject文件

-keep class org.json.** {
   *;
}

其實想想也不應(yīng)該,排查了這么久,看提示就很明顯了,大意了沒有閃。

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

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

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