Signed app crashing and unsigned apk running

前端 未结 1 1862
悲&欢浪女
悲&欢浪女 2021-01-25 02:01

This issue might be related to some SO questions as i searched a lot here, but no any post helped me. My app running when it is unsigned but it crashes instantly when i run the

相关标签:
1条回答
  • 2021-01-25 02:12

    About Proguard

    Proguard basically makes your code smaller and harder to reverse engineer by doing two things:

    1. Stripping out unused code
    2. Obfuscating package and symbol names by renaming human-readable symbols that you wrote to names that are as small (and hard to read) as possible.

    About Your Issue

    It looks like something is using Java reflection to lookup a field named REPLACE, but this field got obfuscated by proguard.

    From your posted stack trace, this:

    com.a.g.<init>(Unknown Source:94)
    

    is the code that is making the reflective call.

    So what the heck is com.a.g.<init>? It's the obfuscated name of a class. The <init> tells me this is a class constructor of some sort.

    But in order to figure out what a and g are, you'd need some sort of mapping between the real symbol and the one that proguard assigned it.

    Solution

    When proguard runs, it generates a symbol mapping file. You can unobfuscate your stack trace using the retrace.sh script (or retrace.bat if you're developing on Windows) that comes with the proguard tool packaged with the Android SDK if you've still got this mapping file and figure out where this is in your code.

    Something like:

    <androidsdkroot>/tools/proguard/bin/retrace.sh -verbose mapping.txt stacktrace.txt > out.txt
    

    Where:

    • mapping.txt is the mapping file created by proguard when it ran
    • stacktrace.txt contains your raw stack trace as you posted in your question
    • out.txt is the filename to receive the unobfuscated stack trace.

    Once you've figured that out, you'll need to add a keep rule to your proguard config file to prevent this from being obfuscated. Or, get rid of the reflective code if you can do that instead.

    Lastly, if the code that is making the reflective call is from a library you don't own, I would go look at the documentation for that library and see if it calls out any keep rules you should be adding to your proguard config file and add them.

    Please see the Android Shrink Code documentation for more information on decoding an obfuscated stack trace.

    0 讨论(0)
提交回复
热议问题