title: Unsatisfied Link Error - OpenCV for Android Non-native
body: <p>A few days ago I <a href="https://stackoverflow.com/questions/11852642/">asked</a> about an <code>UnsatisfiedLinkError</code> from running non-native OpenCV code.  I thought the problem was solved after reinstalling Eclipse and closing/reopening all the packages, but it's back again after I put the OpenCV code into the existing <code>onCreate()</code> method.  </p>
  
  <p>I created a new Android application with an activity called Start.  I then went to project properties and added OpenCV as a library.  Here's the code for the activity (<code>Start.java</code>):</p>
  
  <pre><code>package com.test;
  
  import org.opencv.core.Mat;
  import org.opencv.highgui.Highgui;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.view.Menu;
  
  public class Start extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_start);
  
          Mat Image = Highgui.imread("/image.jpg");
          if (Image == null) {
              AlertDialog ad = new AlertDialog.Builder(this).create(); 
              ad.setMessage("Fatal error: can't open /image.jpg!");  
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_start, menu);
          return true;
      }
  }
  </code></pre>
  
  <p>And here's the log:</p>
  
  <pre><code>08-13 12:26:14.791: E/Trace(1067): error opening trace file: No such file or directory (2)
  08-13 12:26:15.191: W/dalvikvm(1067): No implementation found for native Lorg/opencv/highgui/Highgui;.imread_1:(Ljava/lang/String;)J
  08-13 12:26:15.191: D/AndroidRuntime(1067): Shutting down VM
  08-13 12:26:15.191: W/dalvikvm(1067): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
  08-13 12:26:15.201: E/AndroidRuntime(1067): FATAL EXCEPTION: main
  08-13 12:26:15.201: E/AndroidRuntime(1067): java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.highgui.Highgui.imread_1:(Ljava/lang/String;)J
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at org.opencv.highgui.Highgui.imread_1(Native Method)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at org.opencv.highgui.Highgui.imread(Highgui.java:324)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.test.Start.onCreate(Start.java:18)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.Activity.performCreate(Activity.java:5008)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.os.Handler.dispatchMessage(Handler.java:99)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.os.Looper.loop(Looper.java:137)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at java.lang.reflect.Method.invoke(Method.java:511)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-13 12:26:15.201: E/AndroidRuntime(1067):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Again, this is non-native code, so having an Unsatisfied Link Error doesn't make much sense.</p>