Android-Baidu Map packaging confusing code after map crash resolution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.