Xamarin.android binding Baidu Map SDK encountered problems

Source: Internet
Author: User

In the Xamarin.android binding project, the Map SDK of the LBS map is bound to Baidu, reference https://developer.xamarin.com/guides/android/advanced_topics/ After the binding-a-java-library/binding-a-jar/is set, compile, and then prompt for an error, one of the errors is

It means that the converted CS code has a duplicate type. In theory, the CS code of the conversion should not appear duplicated code, there is repetition, meaning that the jar has duplicate code.

Then see the SDK description of the Baidu map,

It is found that there are "overloaded methods of different parameters" here, so, guess in the conversion process, it is not recognized this with the same method name, resulting in a one-to-two, in CS has a duplicate type code.

However, Xamarin provides a metadata.xml file for overriding the specified method name name.

Find Baidu's SDK (or anti-cheap jar file), the above 2 methods are located OnMapStatusChangeListener   under the interface.

Anti-compilation:

Navigate to this error code file, then look for the name of the code, there is an interface IOnMapStatusChangeListener , below the corresponding interface above

In fact, the code is converted out of the interface here, there is no fault, but the IOnMapStatusChangeListener interface implementation of the code, each interface has a for the EventHandler ,导致出现2个 OnMapStatusChangeStartHandler   compile time when the error occurs!

Now that the problem is found, what is the solution?

Now find a way to change the name,

In the Metadata.xml file, path refers to the name of the paths to be modified, in the converted CS file, each name corresponding to the path is labeled in the comments above, it is very convenient, do not have to find their own!

Here, I'm going to modify the second one OnMapStatusChangeStart , which has 2 parameters, and the modified name is calledOnMapStatusChangeStart2

  <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>

Once the compilation is executed, it will be compiled and passed.

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

Xamarin.android binding Baidu Map SDK encountered problems

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.