Call C# from Android/Java native lib - xamarin

Let's assume that we have a binding library created over native AAR lib.
We are consuming this library in Xamarin Android application.
Is it possible to read data e.g. included in application AssemblyInfo from Java side - by native lib from the binding?

Related

Adding .NET liblaries to Xamarin project

How to add a library for Windows to cross-platform Xamarin project in Visual Studio?
Example, we have some 3rd party service with API and DLL binaries for this API. The service provides DLL for WP, Android, iOS and .NET, but not for Xamarin. Can I use it for Xamarin.Android и Xamarin.iOS?
I have tried to connect WP or .NET DLL to the projects, but it doesn't work.
I have done something similar.
I created a libs folder under my Droid project and placed the Android-specific libraries in there.
I then added the DLL's to my project (using the Add Files option) and, this is important, changed the Build action to EmbeddedResource.
From there, I could access the packages as expected and work with the library.

Building a C++ PCL library and using it in Xamarin.iOS, Xamarin.Android and Xamarin.Mac

I'd like to build a PCL library, starting from an existing C++ code. This code has some dependencies (SDL, which is available as a NuGet package) and I'd like to know if it's feasible to integrate it in a Xamarin solution (which targets Xamarin.iOS, Xamarin.Android and Xamarin.Mac).
More precisely, the code is hosted here : https://github.com/chunying/gaminganywhere/tree/master/ga/client
If so, do I need to use C++/CX language ?

How do I structure my Xamarin app to ensure crossplatform functionality?

Hey I'm a Xamarin beginner who is a bit confused on how to structure my app to ensure cross-platform functionality while writing the smallest amount of code necessary. I have a library written in C and when using this library previously I would go the NDK route(for android), I now have to use the library for my Xamarin.Android and Xamarin.ios app. I want to know what the best way of achieving this goal is. Do I create a shared library or a PCL? Do I find a way to compile the library into a dll and just include in the Xamarin project?
Linking to C "native" libraries does not really change because you are using Xamarin, you still need to build all the various ARCH types, create universal/fat libs, etc...
On iOS you would be linking to a static lib or loading a .dylib:
iOS Linking/Interop Native Libraries
On Android you would be using your .so just like NDK (Xamarin.Android produces an NDK-based app):
Using Native Libraries on Android
*Note: If you are using Visual Studio, you also can debug your 'native' C/C++ along side your Xamarin.Android C# project.
In your C# code, in order to access methods defined in either one of those, you use Mono's P/Invoke functionality which is the same technology that you would use in .NET to access functions in C-based libraries.
Accessing C Methods from C#

Xamarin Android binding project and Android support libraries

When creating a binding project for a java library that requires the Android Support Library, how should the reference be added? Should the Xamarin Support Libraries be used or should the suport lib jar file be included in the project with a ReferenceJar build type?
I've done it by including the appropriate Xamarin Support Library via Nuget. (You might be able to do it by including the reference jar but I'm not sure)

Using a windows.dll in a Xamarin project to deploy on an iPad

I have a C# library that I want to use in my Xamarin project to deploy to an iPad.
Lets suppose the C# library is stored as MyUtilities.dll.
For a regular Windows app, I'd add MyUtilities.dll to my project Resources and then have a
using MyUtilities;
statement in the class where I wanted to use classes from that library.
How do I accomplish this same thing using Xamarin in an iPad app?
You will need to rebuild your library from the source using the Xamarin.iOS compiler. After that you would reference the same way you do in a Windows app - by either including a Reference to the dll in your project, or by including the Library project in your solution and referencing the project.

Resources