Android code obfuscation causes problems, fast locating, and android Obfuscation
Problems caused by code obfuscation and quick locating
During code obfuscation and packaging, the third-party libraries used and the conventional android obfuscation and shielding are blocked, but the generated apk will crash during running. There is a reason for the event, and the reason found later isThe content in the package under the java-gen automatically generated using greendao does not block code obfuscation, resulting in a report when the database is stored.* A (SourceFile :) NullPointerException *
To package the apk in obfuscation mode, the running crash is summarized as follows:
The debug version is okay during packaging, but after obfuscation, the release version sometimes suffers an exception and crashes,
For example:A (SourceFile :) NullPointerException
In this case, you can view the cause of the crash by capturing the UncaughtExceptionHandler crash log or a third-party cloud testing tool, such as cloud testing. There is also a better method under androidstudio.
In androidstudio, you can set debugging and obfuscation. You can use android log to intuitively and quickly locate the problem.
The settings are as follows:
SigningConfigs {release {} debug {}}} buildTypes {release {// Log buildConfigField "boolean", "LOG_DEBUG ", "false" // Enable code obfuscation minifyEnabled true // Remove useless resource files shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt '), 'proguard-rules. pro 'signingconfig signingConfigs. release // use the above signature information} debug {// Enable code obfuscation minifyEnabled true // Remove useless resource files shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt '), 'proguard-rules. pro 'signingconfig signingConfigs. debug }}
For more questions, please pay attention to issues encountered in android Development