前面記錄了兩篇關於如何作混淆的文章,但混淆以後,若是遇到問題,log日誌是沒法查看的,對應的都是混淆後的類、方法,這時候就須要用retrace.bat指令(retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>])將堆棧信息(stacktrace_file)轉換成其真實的類、方法名。java
堆棧信息如何獲取:app
方法一:最簡單的方法直接copy logcat中的堆棧信息保存爲txtthis
方法二是在Application中添加一個異常監聽:spa
Thread.setDefaultUncaughtExceptionHandler(CrashHandler.create(this));
再在CrashHandler中將堆棧信息保存爲文本文件:.net
LogUtils.e(this, "崩潰toString: " + ex.toString()); StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); printWriter.print(TimeUtils.getCurrentTime()); try { dumpPhoneInfo(printWriter); } catch (NameNotFoundException e) { e.printStackTrace(); } ex.printStackTrace(printWriter); FileUtils.savaData("error.txt", stringWriter.getBuffer().toString()); printWriter.println(); printWriter.close(); ex.printStackTrace();// 也別忘了同時打印日誌信息
這樣咱們就可以獲取到堆棧信息,並保存到了本地。接下來就調用先前所說的指令:日誌
retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>
放上幾張實例圖code
(混淆後log輸出內容):blog
調用指令,獲得真實的log信息:get
也可參考:http://blog.csdn.net/yhqbsand/article/details/39369189string