How to add AAR library to xamarin studio?

雨燕双飞 提交于 2019-12-06 14:53:11

问题


Is there any possibilty to add aar library to xamarin studio? I use xamarin studio on mac and i tried add project based on gradle - caldroid to my project. When i try add aar lib to my project with ProjectLibraryZip properties. I can not use any method from this library i c#


回答1:


You would need to add a Java Bindings Library (via Xamarin.Android Java Bindings Library template) to your Xamarin solution and add the .aar file to the Jar folder in the project tree (Embedded Jar Build Action) just as you would a .jar file.

That was the easy part, now simply compiling that Library project will cause the generation of a C# wrapper for ALL the classes/methods/enums/consts in that Jar/Aar file. It usually is never just that simple as not everything translates cleanly from Java to C# so be prepared to manually write some transformation rules to filter out classes, rename methods, etc.. that are located in the project tree at:

├── Transforms
│   ├── EnumFields.xml
│   ├── EnumMethods.xml
│   └── Metadata.xml

Xamarin has a good walk through of the entire process, start there:

  • Binding a Java Library Consuming Java libraries from C#


来源:https://stackoverflow.com/questions/34167406/how-to-add-aar-library-to-xamarin-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!