Afinal jar package for code obfuscation error, afinaljar code obfuscation
Code obfuscation is used today. After the obfuscation, the APP cannot run and an error is reported. Because the project only uses the third-party libraries of Afinal, the answers provided on the Internet are used to avoid obfuscation of the jar package of Afinal, the following statement is written into the configuration file:
-libraryjars libs/afinal_0.5.1_bin.jar-dontwarn net.tsz.afinal.** -keep class net.tsz.afinal.** { *; } -keep public class * extends net.tsz.afinal.** -keep public interface net.tsz.afinal.** {*;}
However, the obfuscated package still reports an error. The error log shows a null pointer exception, turning the code and obtaining the View only using the FinalActivity annotation of Afinal, this may be the reason, So Baidu and Google used the reflection mechanism to find the answer. Therefore, we sometimes need to add the following statement:
-keepattributes Signature-keepattributes *Annotation*
After the addition, the obfuscation is not passed, and then check the configuration before and after, and wonder if there is more
-dontwarn
Because the configuration file has already been prefixed
-dontwarn
So remove
-dontwarn
Still not good, view the error log, because the introduction of android-support-v4.jar, so add:
-dontwarn android.support.v4.**
OK, mixed pass, installation test, OK, also passed.
If you see other problems on the internet, you need to add the following code:
-keepclasseswithmembers class xxx.** { <fields>; <methods>;}
Replace xxx with the package name and Class Name of your inherited afinal.
In addition, there is basically no problem!