The problem of calling native Android jars encountered in xamarin.form (I) naming conflict during compilation

Principle description of official calling Java: https://docs.microsoft.com/zh-cn/xamarin/android/platform/java-integration/working-with-jni

1. Baidu officially selects the function to download the SDK

2. Create Android binding library (xamarin)

3. Put the jar files in the SDK into jars

4. Select embeddedjar for the generation operation

5. Generate a project and report the following error

6. In the metadata.xml file in the transforms folder, add the following code to name the conflicting content and redefine the name.

Official documents: https://docs.microsoft.com/zh-cn/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-Metadata

Reference article: https://blog.csdn.net/qq_ 31403321/article/details/79502182

1 <Metadata>
2   <attr path="/api/package[@name='com.baidu.location']/class[@name='Address']/field[@name='address']"
3         name="name">MyAddress</attr>
4   <attr path="/api/package[@name='com.baidu.mapapi']/class[@name='VersionInfo']/field[@name='VERSION_INFO']"
5         name="name">MyVersionInfo</attr>
6   <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>
7   <attr path="/api/package[@name='com.baidu.mapapi.search.poi']/interface[@name='OnGetPoiSearchResultListener']/method[@name='onGetPoiDetailResult' and count(parameter)=1 and parameter[1][@type='com.baidu.mapapi.search.poi.PoiDetailSearchResult']]" name="managedName">OnGetPoiDetailResult2</attr>
8 </Metadata>

7. After completion, there is a generated DLL in bin for xamarin.android project to call.

Very comprehensive reference articles: https://blog.csdn.net/qq_ 31403321/article/details/79489078

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>