Problems with binding Baidu map SDK to xamarin. android: xamarin. androidsdk

Source: Internet
Author: User

Problems with binding Baidu map SDK to xamarin. android: xamarin. androidsdk

In the xamarin. android binding project, bind the LBS map SDK of Baidu map, refer to the https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-a-jar/ after setting, compile, and then prompt error, one of the errors is

 

This means that the converted CS Code contains repeated types. Theoretically, the converted CS code should not have repeated code, which means the jar has repeated code.

Then, view the SDK description of Baidu map,

 

 

It is found that there is a "overload method with different parameters". Therefore, it is assumed that this method with the same name cannot be identified during the conversion process, resulting in one-to-one conversion, duplicate type code is available in CS.

However, xamarin provides the Metadata. xml file for rewriting the specified method name.

Find Baidu SDK (or anti-cheap jar file). The above two methods are located inOnMapStatusChangeListener  Interface.

Decompilation:

 

Locate the error code file and find the code with the name. There is an interface.IOnMapStatusChangeListener, The corresponding interface above is shown below

 

In fact, the converted code is correct in the interface,IOnMapStatusChangeListenerIn the code of the interface implementation, each interface hasEventHandler, resulting in two onmapstatuschangestarandlerWill occur during compilation!

Since the problem is found, what is the solution?

Currently, one method is to modify the name,

In Metadata. in an xml file, path refers to the path of the name to be modified. In the converted cs file, the paths corresponding to each name are marked in the preceding annotations, which is very convenient, you don't have to find it yourself!

Here, I want to modify the secondOnMapStatusChangeStartIf there are two parameters, change the nameOnMapStatusChangeStart2

  <attr path="/api/package[@name='com.baidu.mapapi.map']/interface[@name='BaiduMap.OnMapStatusChangeListener']/method[@name='onMapStatusChangeStart' and count(parameter)=2 and parameter[1][@type='com.baidu.mapapi.map.MapStatus'] and parameter[2][@type='int']]" name="managedName">OnMapStatusChangeStart2</attr>

If you execute the compilation again, the compilation will pass.

 

Link: https://blog.wuliping.cn/post/note-xamarin-android-binding-baidu-lbs-sdk

Related Article

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.