Unsatisfied Link Error – OpenCV for Android Non-native

After a bunch of searching, I found this:

“3. If your application project doesn’t have a JNI part, just copy the corresponding OpenCV native libs from /sdk/native/libs/ to your project directory to folder libs/.”

So that means copy the \armeabi, \armeabi-v7a, and \x86 folders.

“4. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API. It can be done, for example, in the static section of the Activity class, which gets executed only once, before any instance of the class is created:

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
}

Alternatively, you can put it inside the onCreate method:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_load_image);
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
    [...]
}

Now it works!

Leave a Comment