I'm currently working on generating a static C++ library to wrap with JNI use with Android. Using Visual Studio 2015's new support for Android C++ libraries, I was able to generate a dynamic library (.so), and pulled it into Android Studio. Once it was in the proper directory, it was able to link properly, and I was able to call a native method.
However, doing exactly the same thing, but generating a static library (.a), I continuously got UnsatisfiedLinkError, indicating the library was not found by the app. Everything else was controlled for (i.e. same build settings, same location of the library in the file system, etc).
Has anybody else tried doing this? Is there something special that needs to be done to get Android Studio to recognize .as?
Turns out Android Studio just doesn't support Java 8 yet (and with it, support for linking static C++ libraries). So Microsoft is a little ahead of the game with their support for creating those static libraries. Guess it's dynamic linking for the time being.
Related
I need to build an Android library for use inside a Unity project. There's nothing different about the build process itself and I managed to build a simple plugin library I can use and I can see commands going in and information coming out.
But now I need to include an external library. I know the library works because I have a demo project, an app, that runs on the required device and does what it's supposed to do. But the instructions to integrate it into a project assume that it is an app and so, do not make much sense in my case.
I have scrolled through a dozen manuals about integrating android libraries but none of them seem to work. I would appreciate a set of instructions about how to integrate an external library in an android project, considering the project is, itself, a library, with respect to the latest Android Studio and build tools.
I have gone through all the Android NDK tutorials and built a few simple examples. It seems to me that every example out there from Android Studio revolves around creating a native library attached to an Android application directly. I need to create a native library that is attached to an already existing Android Library. I don't see an example to do this. Is it even possible to hang a native C++ library off an already existing Android Java Library, so the Android Library has access to those native methods, without attaching both libraries (android and native) to a specific application?
Tried in Android Studio to attach a C++ native library to an already existing Android Library, and used CMake as compiler choice, the gradle does not seem to support. The CMakeLists.txt does not seem to be recognized, the "includes" folder is not generated to support the .cpp in the cpp folder, and the native library generates no links I can see to the Android Library methods.
Our project needs a third party library from another company and it is not open source. They provided *.h and *.lib compiled for windows (linux as well), but no cpp.
I didn't think android could use it but I still have tried it in NDK because I have never touch android studio before.
There are many questions, but it all comes to the question, is it possible to use *.lib in android studio(or VS cross-compile) without the cpp of that library?
If the answer is no, I think the only option for us is to request the android version of the library (*.so and *.a files). Is this correct?
I've installed VisualStudio 2015, Xamarin, and MonoGame 3.5. I'm going to build my XNA app for Windows UWP, iOS, and Android.
I've some libraries based on XNA... and I need to build them for the three target systems (Windows UWP, iOS, and Android), but no way to create a library for Windows UWP. I've tried to create a MonoGame Windows 10 Universal Project, but such a project cannot be converted to generate a DLL.
I've also tried to create a Class Library (Universal Windows) project, but then I was unable to add MonoGame.Framework to the references.
I've the same problem when creating a MonoGame Android Project... no way to switch to a library project. The only MonoGame project that can be modified to be a library project is MonoGame iOS Project.
That said, how can I create a class library based on XNA (MonoGame) to be used from UWP, iOS, and Android?
As far as I know you've only got 2 options here.
Portable Class Libraries
Shared Projects
I haven't really used Shared Projects much. The way I understand them is that they allow you to share code between multiple projects as if it lives in a library but it actually gets compiled directly into the referencing project. They can be thought of like advanced file linking.
Portable Class Libraries are a bit of a different beast. I've used them in the MonoGame.Extended project with great success, but it wasn't always easy. The way they work is to provide a subset of functionality that works on all target platforms. They compile to a DLL that can be referenced by any of the projects and you can be confident the code will be the same.
There are a couple of downsides of using a PCL:
you can only use a subset of functionality. Surprisingly, this doesn't get in the way too often.
if the PCL references another library, it also has to be a PCL.
The second point is where things get a little tricky with MonoGame. Typically, MonoGame isn't shipped as a PCL, but a PCL version has been published on NuGet that can be used.
As it stands right now, the NuGet package is a version behind the official release but surprisingly that doesn't really matter because it's a bait and switch PCL which essentially means it just provides the interface to the real DLL that gets used at runtime. In other words, your game will still happily reference version 3.5 even if the PCL is version 3.2 so long as the interface hasn't changed.
There is some talk about improving this situation in version 3.6.
I noticed MonoGame projects are built using .Net 4.5 by default. Regular class libraries default to the latest installed version of .Net which in my case was 4.5.2. I was able to reference a regular class library by going to its project properties and setting the target framework to 4.5. Hope this helps.
I am trying to port my Android Application, developed with Google Android ADT, in Xamarin to make it cross-platform and runnable on iOS devices.
I am ready to translate the needed code from Java to C# but I don't know the best way to manage external libraries.
I am using 3 jars in my App:
android-support-v4.jar
mysql-connector-java-3.0.17-ga-bin.jar
YouTubeAndroidPlayerApi.jar
I tried to embed them following these instructions:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_%28.jar%29
but I'm getting some compilation errors. Here's one of them:
'Com.Mysql.Jdbc.Util' in '[..]\AndroidHelloWorld\JavaBindingLibrary\obj\Release\generated\src\Com.Mysql.Jdbc.Util.cs'
is in conflict with
'Com.Mysql.Jdbc.Util' in '[..]\AndroidHelloWorld\JavaBindingLibrary\obj\Release\generated\src\Com.Mysql.Jdbc.Util.BaseBugReport.cs'
I don't know if it's worth going on trying to fix the errors or it's better to use native libraries for iOS.
As you'll have separate projects for each platform, I would just use the appropriate jars, as there can be differences in the way Youtube works, for example, that would make the android jar unusable in an iOS project.
But about the errors you encountered, it's worth reading this link thoroughly.
You won't be able to use any of your Android specific code or libraries on iOS.
You have two basic options for cross platform development, to create a Xamarin Forms project or create a iOS, Android and Shared project.
If you decide to go with Xamarin Forms you will need to:
* Extract your platform independent code into a shared PCL project
* Redevelop your front end in Xamarin Forms
If you decide to go with separate projects you will need to:
* Extract your platform independent code into a shared PCL project
* Develop an iOS front end project