System.loadLibrary() error

前端 未结 5 1222
你的背包
你的背包 2021-01-12 14:10

I successfully cross-compiled a c++ library with the android ndk-Standalone toolchain then, i created a new android application project into Eclipse and when i put mylib.so

相关标签:
5条回答
  • 2021-01-12 14:23
    try {
           System.load("/data/data/<package name>/lib/libsample-jni.so");
        } catch (UnsatisfiedLinkError e) {
           System.loadLibrary("<sample-jni>"); //remove lib and .so from name
    }
    

    this will help you, Pls. check.

    0 讨论(0)
  • 2021-01-12 14:24

    I recently encountered the same error. After trying out dozens of suggestions from SO, I finally figured out that the error was in my native code. even though android ndk had compiled it without any issues / warnings.

    Try writing a simple main function to test your native code and compile with g++/gcc (or something similar) to check for errors.

    I know its too late for the asker, but hope someone else finds this useful.

    0 讨论(0)
  • 2021-01-12 14:29

    Please specify your .so file like as follow.

     static {
    
         System.loadLibrary("mylib");
    
    }
    

    Hope this will help you.

    0 讨论(0)
  • 2021-01-12 14:39

    If you have your compiled native library (the .so-file) in your lib/-directory, you can refer to it without using the full path:

    static{
      System.load("mylib");
    }
    

    As shown in the tutorial.


    Check to see if you set the right package in your Header-file: How to resolve the java.lang.UnsatisfiedLinkError in NDK in Android?

    0 讨论(0)
  • 2021-01-12 14:45

    People mostly forgot cut "lib" prefix form library name. So if you have "libusb.so" your code must be System.loadLibrary("usb")...

    0 讨论(0)
提交回复
热议问题