How to debug with obfuscated (with ProGuard) applications on Android?

前端 未结 5 1632
遥遥无期
遥遥无期 2020-12-12 12:50

When I got something like this

ERROR/AndroidRuntime(18677): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(18677):     at com.companyname.a.a         


        
5条回答
  •  攒了一身酷
    2020-12-12 12:54

    Add the following lines to your proguard configuration.

    -renamesourcefileattribute SourceFile    
    -keepattributes SourceFile,LineNumberTable
    

    Now your stack traces will include line numbers, and by using the retrace tool that ships with proguard (included in the Android SDK), you are able to debug like normal.

    Note that even if you didn't use these two configuration options, retrace still can output useful information provided you have the mappings file, albeit not totally unambiguously.

    Note: the file with the mappings is produced by the proguard configuration option:

     -printmapping outputfile.txt
    

    In the ant file shipped with the Android SDK, it is set to mapping.txt.

    Good luck.

提交回复
热议问题