1

I am developing a Video Player in Android. Because I need to use code with LGPL license, I have to put the native library in some place.

To load the jniLibs, I'm trying to use System.load(). With jniLibs folder within the project structure everything works fine, but in a different location the program ends with the error below.

did the following:

Manifest:

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>

MainActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {

    final String libPath = Environment.getExternalStorageDirectory().getAbsolutePath()  + "/jniLibs/armeabi-v7a/libvlcjni.so";
    final String libPath1 =Environment.getExternalStorageDirectory().getAbsolutePath()+ "/jniLibs/armeabi-v7a/libiomx-ics.so";

    Log.d("path",System.getProperty("java.library.path"));
    Log.d("path",libPath);

    try{
        System.load(libPath);
        System.load(libPath1);
    }catch (Exception ex){
        ex.printStackTrace();
        System.out.println("\n" + ex.getMessage());
        System.out.println("\n" + ex.toString());

        System.out.println("\nTrace info obtained from getStackTrace");
        StackTraceElement[] traceElements = ex.getStackTrace();
        for(int i=0 ; i<traceElements.length ; i++){
            System.out.println("Method" + traceElements[i].getMethodName());
            System.out.println("("  + traceElements[i].getClassName() + ":");
            System.out.println(traceElements[i].getLineNumber() + ")");
        }
    }

I get this error:

01-25 19:05:24.292      340-340/com.compdigitec.libvlcandroidsample D/dalvikvm﹕ Trying to load lib /storage/emulated/0/jniLibs/armeabi-v7a/libvlcjni.so 0x41bd4bf0
01-25 19:05:24.369      340-340/com.compdigitec.libvlcandroidsample D/dalvikvm﹕ Added shared lib /storage/emulated/0/jniLibs/armeabi-v7a/libvlcjni.so 0x41bd4bf0
01-25 19:05:24.370      340-340/com.compdigitec.libvlcandroidsample D/VLC/JNI/main﹕ JNI interface loaded.
01-25 19:05:24.370      340-340/com.compdigitec.libvlcandroidsample D/dalvikvm﹕ Trying to load lib /storage/emulated/0/jniLibs/armeabi-v7a/libiomx-ics.so 0x41bd4bf0
01-25 19:05:24.373      340-340/com.compdigitec.libvlcandroidsample D/dalvikvm﹕ Added shared lib /storage/emulated/0/jniLibs/armeabi-v7a/libiomx-ics.so 0x41bd4bf0
01-25 19:05:24.373      340-340/com.compdigitec.libvlcandroidsample D/dalvikvm﹕ No JNI_OnLoad found in /storage/emulated/0/jniLibs/armeabi-v7a/libiomx-ics.so 0x41bd4bf0, skipping init
01-25 19:05:24.375      340-340/com.compdigitec.libvlcandroidsample E/VLC/LibVLC﹕ Can't load vlcjni library: java.lang.UnsatisfiedLinkError: Couldn't load vlcjni from loader

I've researched a lot on google and I still do not know how to solve it.

Rostislav Matl
  • 4,294
  • 4
  • 29
  • 53
Joao barreira
  • 91
  • 1
  • 6

1 Answers1

0

It's already four years later, but for other people that search this:

The correct way of loading a native library in Android is placing it in jniLibs. Each architecture has its folder, in this case, armeabi v7a that's the most common one.

When using System.load(path) the system gets all the libraries from jniLibs, then removes the "lib" characters from these names so the resulting library paths in this case would be:

System.load("vlcjni");
System.load("iomx-ics");
Angmar
  • 599
  • 4
  • 9