How to use java libraries in ios project?(codenameone) - xamarin

I need to connect native java libraries for use in the ios environment. In particular, it is necessary to use ready-made support for crypto libraries.
I tried using ikvm(.net core xamarin) for ios. but there is no support for mono-touch.

See this answer from the knowledge base.
You can't use an arbitrary JAR "as is". Please also check the maven dependency discussion in this post.
You can wrap libraries as cn1libs but a library might use arbitrary Java code which might be a problem, see this.

Related

V8 javascript for C++ - precompiled binaries

Can you please tell me if there are pre-compiled binaries of the v8 library somewhere?
Because building from source is just some kind of hell.
V8 developer here. We do not distribute any official binaries.
Building from source should be quite straightforward using the instructions at https://v8.dev/docs/source-code and https://v8.dev/docs/build-gn.
That said, guessing from your other question, you may want to look elsewhere right away, as V8 is not going to help you for that use case: it's a pure ECMAScript engine, so it doesn't know anything about the DOM or related browser functionality. For example, if it saw document.createElement(...), it'd say ReferenceError: document is not defined.

How do your write Xamarin platform specific code in a .net standard library?

How do your write Xamarin platform specific code in a .net standard library?
I want to use namespaces like Xamarin.Forms.Platform.iOS in a .Net Standard Library..
Use case: I want to develop a .net library for my apps which includes a video player for the various platforms. This video player also has to interact with other code in the .net library.
Or is the answer I need to use a shared project or portable library?
You should not include platform specific code or use namespaces like the one you mentioned in your .NET Standard Library, the reason is that .NET is just a runtime environment.
It’s not the the main runtime environment that you would use on iOS or Android. These platforms use Mono - not .NET. Check this or this to see more details for how its structured.
If you need to execute something from your .NET Standard project which is related to platform-specific behavior, use Dependency Injection or Custom Renderers.

Can I use RxJava2 and RxAndroid in a single java class library?

I'm tasked with creating an SDK that can be consumed from both Android & Java applications using ReactiveX programming. I already have an android project using RxAndroid created, but now I need to extend it with RxJava2.
The question I'm facing is whether I should create 'regular' java class library and use it for both scenarios or create 2 separate packages (which would mean a lot of duplicate code + maintenance).
Is this even possible? And if so, is it a good practice?
whether I should create 'regular' java class library and use it for both scenarios
Yes. What I would do to start is simply change your Android library project to be a standard Java library and replace RxAndroid dependency by RxJava. Most code should still compile. Code which doesn't will mostly use schedulers provided by RxAndroid and can be changed to take Scheduler parameters.
Then create an Android Library project which depends on the Java Library and put the RxAndroid-specific code there.
As an addition to #AlexeyRomanov's answer, feel free to check out this library which could be used for both Android and Java projects: https://github.com/JakeWharton/RxRelay.
Its basically an extension to RxJava, but it might give you a solid idea where to go. Good luck!

Xamarin Shared Library and PCL

What is the exact difference between xamarin shared project and portable class library?
When to use shared library and when to use portable class library?
Is this possible to write native functionality in shared projects like showing alert,accessing camera and use it for both android and iOS?
Can anyone please explain me.
In shared projects each code file will be compiled for each destination (Android, iOS, Windows Phone etc). You are able to include platform specific code by using #if compiler directives.
When you want to access the camera you need to write the access code inside an #if block for all destinated platforms. This can mess up your code but it can be easier to find the different implementations.
Learn more: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/shared_projects/
Protable Class Libraries (PCL) are compiled against a general .NET subset which is compatible to all platforms you want. So you can access System.Net.Http but you cannot access any platform specific code. If you want to access the camera inside the PCL code then you need to access it by a generalized interface via dependency injection. There are some pretty good frameworks helping you to archieve this goal. One of the most famous is MVVMCross (https://github.com/MvvmCross/MvvmCross/wiki). Learn more about PCL: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/#Portable_Class_Libraries
I personally perefer PCLs because the code is much easier to read without any compiler directives. Using MVVMCross you are able to use plenty of plugins via NuGet. So you don't need to write your own classes for camera access, showing alerts etc.

One has to provide four different libraries with Visual Studio?

This post and this post says that with Visual Studio, the run time library can be static/dynamic, and it shouldn't be mixed. Even one can have debugging version/release version for the library. And there are four possibilities (static/dynamic and debug/release).
So, with Visual Studio, the library provider has to provide four different versions of the same library?
ADDED
I tried to link CppUnit test (debug) with release build library, and I got an error. So, I wondered normally library provider might need to provide all the possible combination of libraries.
depends..
under normal cicrcumstances you only provide a realease version. Then you have the option for static/dynamic. In the case of static, you don't have to provide anything since it's static: your lib already contains all functions from the crt it needs. In case of dynamic, it also depends: if you expect your clients to build applications using your lib, they already should have the required lib on their build machine. Else, yes, you can provide them with a crt installer for the dynamic release version (or just ship the corresponding dlls but that's considered rather bad practice)
Also if I remember correctly, you cannot redistribute the debug versions of VS's debug libraries, so in the end this would mean the library provider should only provide one version.
This is really the case with ANY C++ library (we have the same 4 options in our Unix side builds).
Please note that you only have to provide the debug versions if you intend them to be used by other developers, who will need them to debug - otherwise, for end users, you can only provide optimized ones.

Resources