Xamarin Android loading .so dynamically - c#

In a project, i have a .NET wrapper that use a .so build as a AndroidNativeLibrary.
Since the .so add a lot of weight to the APK(several MB), and that the features found in the .so library will not be used in all installations of the application, i was wondering if it is possible to dynamically load the .so from the sdcard for example?
What would be my other options, beside maintaining two versions of my application?
Thanks in advance!

The short answer is No.
Starting with Android N Google is changing the way shared library are accessed due to security (and app versioning). Consult the NDK link below for full details.
Your app references a library that is not included in its APK. For example, this could happen if you tried to use your own copy of OpenSSL but forgot to bundle it with your app's APK
Ref https://developer.android.com/preview/behavior-changes.html#ndk
Ref: https://releases.xamarin.com/beta-release-cycle-7-service-release-1/

Related

Silent printing in UWP follow up

Last year Stefan Wick provided an answer to a question about silent printing in UWP applications How to silent print from a UWP application, along with a sample app showing a solution.
That app won't work for me, as it can't access local settings. The error is that it needs Windows.Foundation.FoundationContract 3.0.0.0. The UWP project has access to that, but the Win32 project does not, and I can't figure out how to reference it (Nuget won't recognize it and I can't find a viable dll to download).
Any suggestions on how to get this to work?
Or any alternatives to get UWP to print directly to a USB connected receipt printer without requiring the user to see the print preview dialog?
Thanks!
You can reference the Windows.Foundation.FoundationContract directly from the References folder in C:\Program Files (x86)\Windows Kits\10\References\. Specifically this library is in the 10.0.17763.0\Windows.Foundation.FoundationContract\3.0.0.0 subfolder.
For more info on how to reference the libraries see this blogpost.

How to build AIR Native Extension for Windows with C#?

I recently developed native extensions for mobile projects on Adobe AIR (Android and iOS).
I want to port these ANEs for desktop projects on Windows and OSX. The OSX part is not a problem because it uses the same mechanisms as for iOS. The problem is essentially on the Windows side.
Adobe AIR offers bridges to write the native part in C / C ++, I prefer to use C# to simplify the task and access more simply .NET libraries.
Has anyone ever heard of experiments or viable projects to code a native Adobe AIR extension with C#?
I have not found a complete solution to achieve this:
Create a DLL in C # including access to FlashRuntimeExtensions.h (C Header file)
Be able to use .NET libraries from this unique DLL
Produce only one DLL file
Do not use the flash.desktop.NativeProcess library
Thank you for your help or a different point of view on these issues.
According to Extending AIR, you just need access to any function on your DLL regardless what native method you used to create it.
This means that you still need to use a C++ project to link AIR to your native library but the main code can be done on C#. So you export your main code/logic into a DLL from C# and then use the C++ bridge project to Link both DLL and flash.
This link could also be useful : Windows ANE - tutorial introduction
A developer sent me this link to TUARUA's FreSharp GitHub page.
It corresponds exactly to the subject of my question. I share it so that everyone can see how to create an ANE (AIR Native Extension) from C# under Windows.
So I will be able to resume my development and port my libraries for desktop computers.
Thanks to everyone.

How to use GStreamer in ASP.NET application?

I want to develop an ASP.NET application using GStreamer, especially the GStreamer Editing Services (GES) module in the server end.
To do this I googled it and didn't find any detailed material about how to combine them together.
So I decided to try it myself.
Firstly I downloaded the two installer files from here and successfully installed them on my Windows 7 computer.
Next I created a C# project in VS2013 and tried to reference the DLL files in the bin folder of the installed SDK.
Then I found that they are native DLL files and I had to P/Invoke them in my project if I need to use any function in the GStreamer library.
Also I had to rewrite all the GStreamer classes I need in C# code because there is no way to export them from those DLL files, which requires me a lot of work.
This makes me wonder that if I'm on the right way.
Is there an easier way to let me use GStreamer in my ASP.NET application?

Consuming .so files of android in c#

I have a .so files which I was using it in java code which compiled to be used on an Android machines, now I forced to use some of the functionalists that are defined in the .so files, in a .NET c# application.
How can I reference or consume .so files in the c# program?
I don't think this is possible.
.so is a shared object, which is machinecode (Android Native Interface) for the phone / emulator.
I don't know C# very good, but I don't think there is any interface with which you could access the members of the .so.
Beside of this is .so the shared objects format for linux, and .NET runs mostly on windows.
Also, the .so is most likely compiled for ARM processors on phones, so it would need an emulator to run t on windows.
You see, there is a huge gap between these technologies.
If you want to use this on a PC, no, you can't use the file directly. You need to get the source and recompile to a DLL which you can use from .NET via Platform Invoke (IIRC the name). What you have is most probably ARM code, and you will need x86 for a PC.
Monodroid might work an Android device, since it most likely just compiles to Android code. I've never used it though, so don't quote me on this.

WinRT and DLLs: What exactly am I allowed to use?

It's not all together clear to me, so I am hoping someone here knows the answer. I am using the C# Json.Net and the C# HtmlAgilityPack both built from sources for "Any CPU". I've noticed that both of these include using directives that reference assemblies that don't seem to be available in Metro yet they both build fine.
If I reference them, does this mean my app will thunk to unmanaged code?
What exactly causes thunking to unmanged code?
Why are DLLs allowed to reference assemblies that are not available to WinRT and my app is not?
Will this fail the windows store approval process?
What are the general rules for DLLs I include with my app that I need to worry about?
Thanks in advance!
When developing apps that target WinRT, the app should only use the API's available in Windows 8 WinRT. The API's are defined in WinMD files. If the app used the desktop API's, then it will be rejected during the Windows store approval process.
Imagine this scenaio. You developed a WinRT app that uses .NET DLL's from desktop mode (client profile). The app is deployed in Windows store and user downloads it on ARM tablet. The application will crash as it does not have the desktop (client) .NET DLL's on the ARM devices.
so this brings us to the question on what .NET classes we can use while developing apps for WinRT. The article http://kishore1021.wordpress.com/2012/08/06/what-is-portable-class-library-project-in-visual-studio-2012-net-4-5/ lists the .NET classes available for WinRT application development.
Change all open source projects dependencies to target WinRT. See if some methods / classes in WinRT are missing so the code does not compile. Try to find the alternative methods/classes.
Such as List.FindAll(), change to Linq Where()

Categories