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