先說結(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)該,排查了這么久,看提示就很明顯了,大意了沒有閃。