BUILDING THE XAMARIN WEBRTC ANDROID LIBRARY: USING XAMARIN BINDINGS.
In the previous articles, I showed you how to build and compile the WebRTC library for iOS and Android. In the end of both articles, we got a framework file for iOS and a aar file for Android.
As a Xamarin developer, these file formats are not compatible with your Xamarin Forms, Xamarin iOS or Xamarin Android projects. To solve this issue of incompatibility, we need to convert these libraries into a .DLL (DYNAMIC LINK LIBRARY) that is compatible with Xamarin.
Fortunately, in the Xamarin framework’s arsenal, there exists a tool for this referred to as XAMARIN BINDINGS and it is well documented how to create Xamarin binding libraries from several Native Library formats.
For this article we will be primarily focusing on Binding an AAR Library/File. The Link below is a detailed Microsoft documentation that shows you how to set up and build a Xamarin binding library using .AAR file:
You might have realized that once you attempted to build the library, you were met with an error like the one pictured below:
This is due to rule in C# which states a property cannot have the same name as the class it belongs to. For instance, a class called “WebRTC” cannot have a property named “WebRTC”. A solution to this is to open the Metadata.xml found in the Transforms folder of your solution and add the following line to the file.
<attr path=”/api/package[@name=’org.webrtc’]/class[@name=’StatsReport.Value’]” name=”name”>StatsValue
This renames the offending property name “StatsReport.Value” to “StatsValue”. Once this is done, rebuild your project in either Release and/or Debug mode and it should build successfully.
If you navigate to your bin folder you should see either a Debug or Release folder depending on the build configuration you selected. Inside these
folder, you will see the DLL file that was created.
The code base for this article and other relating articles can be found here:
If you want to delve further into troubleshooting tips for Xamarin Binding of .AAR Libraries, you can check out this link: