1

[This is a common Android question, don't look on the Gstreamer keywords]

I trying to use Gstreamer on Android via Xamarin.Android(in the Visual Studio), so I built this sample project on the Ubuntu, took the compiled libtutorial-5.so and libgstreamer_android.so libraries and added them into the Xamarin.Android project as AndroidNativeLibrary's. When I try to use libgstreamer_android.so using DllImport, then all going ok, but when I try to use libtutorial-5.so (of course using DllImport), then I get:

DllImport unable to load library 'dlopen failed: could not load library "build/obj/local/armeabi-v7a/libgstreamer_android.so" needed by "libtutorial-5.so"; caused by library "build/obj/local/armeabi-v7a/libgstreamer_android.so" not found'.

This error occurs because libtutorial-5.so depends on the libgstreamer_android.so. libtutorial-5.so trying to find libgstreamer_android.so library in build/obj/local/armeabi-v7a/libgstreamer_android.so location.

But of course these two libraries are located in the lib/armeabi-v7a directory and even if I replace all two libraries or just libgstreamer_android.so in this location, then I still have this error. So I think I have two options:

  • How can I replace library in the real build/obj/local/armeabi-v7a directory(because if I use this location in the Solution Explorer then I still have this issue)?

OR

  • How can I change path of the library on which my first library will depend in the Android Studio or just in the .mk files(on the .so building stage)?
konstantin_doncov
  • 2,725
  • 4
  • 40
  • 100
  • Why don't you add all the required libraries to the project and mark them as AndroidNativeLibrary? it will take care to put them in its place – Gusman Feb 06 '16 at 18:37
  • @Gusman hm... It's strange but I wrote that I added them(two libraries: which depends and on which depend) into the Xamarin.Android project as AndroidNativeLibrary's. – konstantin_doncov Feb 06 '16 at 18:43
  • Whops. sorry, did not read that... hmm, are you sure they're the correct abi? is VERY strange XAndroid did not put them on place... – Gusman Feb 06 '16 at 18:46
  • @Gusman I think yes, because I can use these two libraries(and each other) autonomously, but this error has occurred **only when first library depends on the second in the strange location(`build/obj/local/armeabi-v7a`) which I have in the Android Studio project, but haven't in the Xamarin.Android project**. I think I have an issue due to this, and I need to fix it. – konstantin_doncov Feb 06 '16 at 18:54
  • try one thing, create an android package, rename the apk to zip, uncompress it and check if the library is there. – Gusman Feb 06 '16 at 19:00
  • @Gusman thanks, but unfortunately I can see both these libraries. – konstantin_doncov Feb 06 '16 at 19:05
  • So they're in place? then the error is on the library, it must be looking for it on another place... – Gusman Feb 06 '16 at 19:06
  • @Gusman sorry for the misunderstanding, I mean that can see them in the `App2.App2.apk\lib\armeabi-v7a` but not in the `App2.App2.apk\build\obj\local\armeabi-v7a` or something like this. – konstantin_doncov Feb 06 '16 at 19:14
  • Ok, the problem IS in your library, the reference is wrong, it has been added with a path, "/build/obj/local" which is wrong, the correct place for a library is in /lib/(abi), as the second library expects it to be in a concrete place it does not work as xamarin is putting them in the right place, you must correct your library (aret you using by a change a compiled library in debug mode? Android Studio can change paths when doing debug, maybe that is the problem). – Gusman Feb 06 '16 at 19:18
  • @Gusman ok, thanks, I will try to rebuild them... – konstantin_doncov Feb 06 '16 at 19:20
  • @Gusman I opened `Android.mk` in the Android Studio and now I can see string `LOCAL_SHARED_LIBRARIES := gstreamer_android`. I think this is what I need, but how can I change this variable? Because I don't now where it was set. – konstantin_doncov Feb 06 '16 at 20:06
  • Sorry, no idea, I don't use Android Studio, when I did native Android was pre-AS I used Eclipse – Gusman Feb 06 '16 at 20:07
  • @Gusman I tried to change this library but still have this error, I don't know how I can change it. I also tried to use `Java.Lang.JavaSystem.LoadLibrary` for manually loading of library but got an error `Could not retrieve class org.freedesktop.gstreamer.GStreamer`. Maybe you know how can I fix it? – konstantin_doncov Feb 06 '16 at 21:35
  • Sorry, no idea, but, you're creating your own Java library, why did you created it in java instead of create it in C#? this way you will get ride of all the errors as you will not need to include a library referencing the other library. If you need help with the bindings maybe I can help you. – Gusman Feb 06 '16 at 21:44
  • FYI: don't need to do nothing, the bindings already exists... http://gstreamer.freedesktop.org/modules/gstreamer-sharp.html – Gusman Feb 06 '16 at 21:48
  • @Gusman whoops, I think I made a mistake: I tried to load C library using `Java.Lang.JavaSystem.LoadLibrary`. Is it correct? If no, then how can I load NDK C library(avoiding DllImport)? – konstantin_doncov Feb 06 '16 at 21:51
  • Yes, it is correct: Java.Lang.JavaSystem.LoadLibrary("libgstreamer_android") – Gusman Feb 06 '16 at 21:53
  • @Gusman and about bindings: I already tried them, but I have no idea how to use them in the Android :( you can check [my post](http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-sharp-for-Android-td4675613.html) – konstantin_doncov Feb 06 '16 at 21:56
  • I'm downloading the sdk to take a look at it, I can't promise anything but at least I will check if it's possible to use. – Gusman Feb 06 '16 at 22:08
  • @Gusman anyway many thanks to you! Because I can't get any information about this issue, any help will be useful! – konstantin_doncov Feb 06 '16 at 22:14
  • Ok, there is a possibility, if you're using VS2015 then it can compile native Android libraries (as the gstreamer needs a native part to work plus the gstreamer library), if you look at the examples you can see there is a small c file which does the calls to the gstreamer and then it comunicates with the java part, you can replicate this exact behavior creating the native part plus the android project. Here is an example on how to do it: https://blog.xamarin.com/build-and-debug-c-libraries-in-xamarin-android-apps-with-visual-studio-2015/ But beware, this is going to be a difficult work. – Gusman Feb 06 '16 at 22:17
  • @Gusman what will be easier: use gstreamer or gstreamer-sharp? How do you think? – konstantin_doncov Feb 06 '16 at 22:29
  • gstreamer, for sure, gstreamer-sharp relies too much in the specific library for desktop (I did looked at the code), and the Android examples can be ported 1:1 using the native library on Visual Studio. – Gusman Feb 06 '16 at 22:31
  • @Gusman ok, this is making progress! Thanks! And one more thing: are your previous comment was about gstreamer or about gstreamer-sharp(`Ok, there is a possibility, if you're using VS2015 then...`)? – konstantin_doncov Feb 06 '16 at 22:37
  • 1
    gstreamer, take the android examples and reproduce it on vs, you need to create a native c library (which the examples also do) as the post I linked, then copy the code (it will be copy/paste, it's pure C) and add the Java code as C# code, it will have some fails, for sure, and you will need to configure VS to use the SDK, but it's doable. – Gusman Feb 06 '16 at 22:42
  • http://stackoverflow.com/questions/35329621/where-are-all-the-shared-libraries-stored-on-android – Ciro Santilli OurBigBook.com Mar 01 '17 at 14:51

0 Answers0