Develop with LibVLC for android on Windows
Asked Answered
M

2

11

I've struggled to even get a demo application running with Android-LibVLC.

I can only find documentation for linux and can't get the application to run on my device (although it compiles).

When I launch the application it logs:

12-16 15:58:19.572    9121-9121/? E/VLC/LibVLC﹕ Can't load vlcjni library: java.lang.UnsatisfiedLinkError: Couldn't load vlcjni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.compdigitec.libvlcandroidsample-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.compdigitec.libvlcandroidsample-1, /vendor/lib, /system/lib]]]: findLibrary returned null
12-16 15:58:19.667    9135-9135/com.compdigitec.libvlcandroidsample E/VLC/LibVLC﹕ Can't load vlcjni library: java.lang.UnsatisfiedLinkError: Couldn't load vlcjni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.compdigitec.libvlcandroidsample-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.compdigitec.libvlcandroidsample-1, /vendor/lib, /system/lib]]]: findLibrary returned null

I've compiled the project APK with the org.videolan.libvlc directory classes as part of the source root and with the jni directory in the same module and failed, I've also included the whole VLC module as a separate library module and made it a dependency, this also failed.

Does anybody have a proven method to configure/build an android project with LibVLC, from windows? Or a link to instructions/documentation? (I haven't been able to find anything).

The goal is to replace my android MediaPlayer reliant classes to a library/implementation that supports more filetypes / codecs.

Milner answered 16/12, 2013 at 17:33 Comment(0)
D
2

While building in windows your will get warning saying "Android.mk:iomx-hc: non-system libraries in linker flags: -lgcc -lstagefright - lmedia -lbinder" you will get them for multiple files. And it also warns "Android NDK:This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES" So even if you get the builds output it will not have the required files. And hence you are getting the error while running the application.

Now if you look into Android.mk you will find

include $(CLEAR_VARS)

LOCAL_MODULE     := libiomx-gingerbread
LOCAL_SRC_FILES  := ../$(VLC_SRC_DIR)/modules/codec/omxil/iomx.cpp
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/modules/codec/omxil $(ANDROID_SYS_HEADERS_GINGERBREAD)/frameworks/base/include $(ANDROID_SYS_HEADERS_GINGERBREAD)/system/core/include
LOCAL_CFLAGS     := -Wno-psabi
LOCAL_LDLIBS     := -L$(ANDROID_LIBS) -lgcc -lstagefright -lmedia -lutils -lbinder

include $(BUILD_SHARED_LIBRARY)

I downloaded the source of vlc from here and after extracting the source i was able to find "extracted_path"\vlc-2.1.4\modules\codec\omxil\iomx.cpp. So if you can change the include path for VLC_SRC_DIR to the directory where the source of vlc is extracted on WINDOWS machine I think you should be able to compile it. If not use a virtual machine running linux to compile the project.It also requires Archive libraries (.a) which you won't find in the source of vlc. So you will have to first build the source of vlc and then include all the stuff in the project. I think linux in virtual machine is your best bet.

Devy answered 22/2, 2014 at 5:1 Comment(0)
F
2

Interesting project there. The Unsatisfied Link error usually means, that the Native Library (probably a Shared Object or something) was not found. Did you run "ndk-build" from Android NDK inside the "jni" folder of the project?

You also said, that you added the Java-Sources from the Library Project to you Java sources. That is probably not the right way to do it. Consider this:

  1. Underlaying those Java Classes there is JNI-Code, that is written in C/C++. What you want to achieve, is that this so-called native code is compiled into a library object that can be loaded/run on Android. To this end, one usually writes an Android.mk file, located in the "JNI" Folder and runs "ndk-build" to build those sources.
  2. There needs to be some Wrapper/Binding Code in Java, that calls those native C/C++ functions. The binding of Java-Calls to C-functions is done by package and class names. Thus, if you move around code, you are likely to destroy those bindings. Unless you know, what you are doing, I would thus recommend, that you leave such an Android Library project, as is and just include the project into your Application Project through Properties -> Android from Eclipse.

Also, you might want to check this project. https://github.com/fscz/FFmpeg-Android

Felting answered 21/2, 2014 at 11:7 Comment(4)
I use this ffmpeg based mediaplayer library: github.com/wseemann/FFmpegMediaPlayer. It has prebuilt libraries so its easy to get started or you can compile themIdell
Unfortunately none of that helps as it's steps we've taken already, including using the source as-is as a library project :( but thank you for a very well thought out replyMilner
The error message "Can't load vlcjni library" indicates clearly that the library object was not found. Check that inside the "libs" folder of the library project there is are folders "arm-v7a" "arm", etc. and that they contain a file libvlcjni.so. This is usually achieved by running ndk-build from inside the jni folder. Does the build run successfully? Don`t forget to refresh the project afterwards. And then refresh the project that depends on the library project and run/launch the application.Felting
I'm now at home and can't test this but I will do soon. I'm going to award you the bounty anyway as you have tried to help and could use the reputation boostMilner
D
2

While building in windows your will get warning saying "Android.mk:iomx-hc: non-system libraries in linker flags: -lgcc -lstagefright - lmedia -lbinder" you will get them for multiple files. And it also warns "Android NDK:This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES" So even if you get the builds output it will not have the required files. And hence you are getting the error while running the application.

Now if you look into Android.mk you will find

include $(CLEAR_VARS)

LOCAL_MODULE     := libiomx-gingerbread
LOCAL_SRC_FILES  := ../$(VLC_SRC_DIR)/modules/codec/omxil/iomx.cpp
LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/modules/codec/omxil $(ANDROID_SYS_HEADERS_GINGERBREAD)/frameworks/base/include $(ANDROID_SYS_HEADERS_GINGERBREAD)/system/core/include
LOCAL_CFLAGS     := -Wno-psabi
LOCAL_LDLIBS     := -L$(ANDROID_LIBS) -lgcc -lstagefright -lmedia -lutils -lbinder

include $(BUILD_SHARED_LIBRARY)

I downloaded the source of vlc from here and after extracting the source i was able to find "extracted_path"\vlc-2.1.4\modules\codec\omxil\iomx.cpp. So if you can change the include path for VLC_SRC_DIR to the directory where the source of vlc is extracted on WINDOWS machine I think you should be able to compile it. If not use a virtual machine running linux to compile the project.It also requires Archive libraries (.a) which you won't find in the source of vlc. So you will have to first build the source of vlc and then include all the stuff in the project. I think linux in virtual machine is your best bet.

Devy answered 22/2, 2014 at 5:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.