I have a xamarin project which runs on Android, iOS and Windows Phone 10. This project is write in c#.
And I want add a C++ in my solution and each project can use C++ function thanks to Interrop. I can add a c++ project on Android and iOS by adding a shared library but but I can not add it to my UWP project. If I want use a C++ library I need to use a Windows Runtime Component. But I want just 1 shared code for Android, iOS and UWP, I think I need to create a dynamic or static library but I do not know how then reference it in my UWP project.
Related
I want to develop a library for Xamarin Forms just like how we do in native iOS and android, like .framework or .a for iOS and .aar and .jar for Java Android.
I researched a lot and saw that we can create a nuget Packages based on Platform dependent environment .. But In my case I want to create a SDK which will only make HTTp calls and hence I don't want to use any platform dependent code .
I also found that we can create .Net Standard Library, but didn't get any useful material or Link to work Forward.
My Requirement is to create a SDK which can be used in Xamarin Forms Project . Can SomeOne Please guide me.
Thanks in advance
I know that I can add Android library (jar/aar) to Xamarin project. If I compile this project for iOS, will it work ? I read that it is not possible because of iOS do not have jvm. Is this situation same for Xamarin ?
Is this situation same for Xamarin?
Yes, you can't add jar to Xamarin.Ios.
Xamarin.Android or Xamarin.Ios is just a wrapper for Native Android or Ios.
You can use c# to code Xamarin.Android project, and run the Xamarin.Android project on a Android device,these all based on Android Callable Wrappers and Managed Callable Wrappers.
I have a Chip card reader application which is written by C# and C++ lib as a low-level layer.
Now I want to have the same application in IOS and Android.
So for to achieve this, I have setup the XamarinSDK in VS2017.
I have created the sample android app and imported my existing card reader c# class library and I have calling C++ methods using DllImport inside the C# library and finally compiled both successfully without error.
But when I run the APK on the device it showing exception when calling C++ lib from C# lib.
The code flow is like below image.
So can anyone help me about how to achieve this same?
Highly appreciated your help on this.
Your libs must be compatible with the Android platform. If they're written to Windows or other platform you have to recompile and maybe adapt them. The C# lib tend to be an PCL or .Net Standard lib and the C++ lib have to target the android platform.
I don't have experience with C++ Android development but all C++ applications and libraries have to be compatible with the platform they run.
Like I want to convert a C++ project that I made in VS to an android app. And I found out that there is a Visual C++ android development kit available in VS. So will there be any need of using Java? (as building an android app usually requires)
You can indeed create a Visual Studio project that uses the Android NDK to build an Android app from pure C++ code. The C++ code is compiled into a library that a little bit of Java glue code calls into, and this combination, along with your resources, is packaged into an .APK that you can install. You don't have to edit or otherwise modify the Java code at all; all your program logic can be in C++.
Technically speaking, you can't easily convert an existing VS project into an Android project, but you can copy your code into a new project that creates an Android app, or copy it into a shared code project that is picked up by a project that creates a library for Android that you can call from an app written in either Java or C++. The project templates in VS give simple examples of doing each of these things.
I'm almost completely new to Android development, but can I use the new Android Studio to edit and run C++ code? Will I be able to import and use a C++ library with Android Studio in order to make an Android app?
Although it might be possible with some wrapper like explained here : android studio with cpp (not sure I did not try it) I suggest you to use Java as a programming language. You can also make your android application with unity by using C# or JavaScript if its a game.
Of course you can. Use android NDK for this: https://developer.android.com/tools/sdk/ndk/index.html