Objective:
Before the development of the project to use Baidu Map, the test is not a problem; however, the problem of the map crashes after packaging and confusion, the project has been completed, while you have leisure time to quickly share their solutions.
Problem phenomenon:
Baidu Map before the development of some small problems, a search found that everyone seems to have encountered such problems, we know that Baidu Map API needs to apply key, fill in the security code.
The security code consists of the following: The SHA1 value of the Android signing certificate ";" PackageName (i.e.: Digital signature semicolon package name)
Debug words, code has not been confused, Baidu map normal use, only after packaging only after the problem.
However, basically released to the app market apk is generally encrypted, a bit of intellectual property protection awareness of the code will be confused,
will use a set of their own keystore, reset "Security Code", export apk without reporting any errors
But when I loaded the mobile phone using Baidu map location, the map was drawn more than half, died, left the log console there is such a sentence
Com.baidu.platform.comapi.map.MapRenderer.nativeRender (Native Method)
Analysis Reason:
Here only put a sentence, there are a lot of unusual information Kazakhstan, after Google search, and then Baidu Map official website and carefully read it, really kung fu, or let me find, in fact, the official has clearly pointed out
3.6.5 Why does my program run without confusion before it can be run?
Raster SDK (i.e. 1.3.5 and previous versions):
If you are using Proguard to confuse, add the following statement in your confusing configuration file:
-keep class com.baidu.mapapi.** {*;}
Vector version of the SDK (i.e. 2.0.0 and later versions):
If using Proguard, the following configuration is provided for reference:
#-libraryjars Libs/baidumapapi_v3_1_0.jar replaced with the version of Jar-keep class com.baidu.** {*;} -keep class vi.com.gdi.bgl.android.**{*;}
Other obfuscation tools also make a configuration similar to this, specifying that the classes and methods in Mapapi are not confused.
Solution Solutions
Add the following in the Proguard-project.txt (referring to the Baidu baidumapapi_v3_1_0.jar This version of the jar package, replaced by their own package is good),
-libraryjars Libs/baidumapapi_v3_3_0.jar-keep class com.baidu.** {*;} -keep class vi.com.gdi.bgl.android.**{*;}
Actually found the reason is the code is confused when the line, plus after the export, map function can be used normally
-keep class vi.com.gdi.bgl.android.**{*;}
Android-Baidu Map packaging confusing code after map crash resolution