Code obfuscation causes problems, quick positioning
When the code is confusing, the third-party library is masked, and the normal Android obfuscation screen is used, but the resulting apk runs or crashes. There must be cause, and later analysis to find the reason is the use of Greendao automatically generated Java-gen under the package content is not masked code confusion, resulting in the storage of the database, reported *a (sourcefile:) NullPointerException *
Obfuscation package apk, run crash summary is as follows:
When we pack, the debug version is fine, but the release version sometimes crashes unexpectedly when confused.
For example:A (sourcefile:) NullPointerException
In this case, you can see the cause of the crash by grasping the Uncaughtexceptionhandler crash log or by a third party such as the Cloud tool. There is a better way to Androidstudio under the sun.
In Androidstudio can be set debug under also confusion, through the Android log intuitive, fast positioning problems
Set the following
Signingconfigs {release {} debug{}}} buildtypes {release {//Do not display logBuildconfigfield"Boolean","Log_debug","false" //Turn on code obfuscationMinifyenabledtrue //Remove useless resource filesShrinkresourcestrueProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro 'Signingconfig Signingconfigs.release//Use the above signature information}} debug {//Turn on code obfuscationMinifyenabledtrue //Remove useless resource filesShrinkresourcestrueProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro 'Signingconfig Signingconfigs.debug}}
More questions please focus on Android development problems
Android code obfuscation causes problems, quick positioning