title: phonegap android plugin using a native library
body: <p>I'm trying to create a phonegap plugin for an android device, sadly my Java is terrible.</p>
  
  <p>I have a simple helloworld project i'm working in to try and get this going.
  I've created a plugin which loads fine and works ( just a simple return string example ) </p>
  
  <p>From this i then have tried to add my native library code.</p>
  
  <pre><code>public class Medida extends CordovaPlugin
  {
  
  static {
      System.loadLibrary("finger");
  }
  
  public native static int SFM_Init(byte[] dev);
  </code></pre>
  
  <p>The error message i keep encountering is: 
  10-28 15:23:03.207: W/dalvikvm(11618): No implementation found for native Lorg/apache/cordova/plugin/Medida;.SFM_Init ([B)I</p>
  
  <p>Now - I'm taking the libfinger.so file from a full JAVA android project and trying to wrap it into a phonegap plugin (why? Because i can code phonegap, but no java).</p>
  
  <p>The files are all been placed in the correct locations
  the libfinger.so file is in the libs/ folder </p>
  
  <p>So my question is - what else do i need to add-in or do to get the JAVA plugin to work with the libfinger.so - so i can call all the clases etc..</p>
  
  <p>Thanks for looking - spents days trying to find out, but there is not much info on calling loadlibrary for plugins which i understand.</p>
  
  <p>John </p>
  
  <pre><code>Main java class
  package org.apache.cordova.plugin;
  import org.apache.cordova.CallbackContext;
  import org.apache.cordova.CordovaPlugin;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import android.util.Log;
  
  
  public class Medida extends CordovaPlugin{
  
  static {
      System.loadLibrary("finger");
  }
  
  public native static int SFM_Init(byte[] dev);
  
  
  static final String LOG_TAG = "Medida.Java: ";
  int fd = 0;
  String retval = null;
  int[] nQuality = {0};
  int[] nBufferSize = {0};
  private final String retSuccess = "OK";
  public static final int REFRESH = 1;
  public static final int ERROR = 0;
  private Thread thread = null;
  private int peripheral_fd = 1;
  
  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
      if (action.equals("dave")) {
          String message = args.getString(0);
          this.dave("Medida CALLING DAVE " + message, callbackContext);
          return true;
      }
      else if (action.equals("scanfinger_getID")){
           this.scanfinger_getID( args, callbackContext);
           return true;
      }
  
      return false;
  }
  
  private void dave(String message, CallbackContext callbackContext) {
      if (message != null &amp;&amp; message.length() &gt; 0) {
          callbackContext.success(" --- Medida FROM DAVE: " + message);
      } else {
          callbackContext.error("Expected one non-empty string argument.");
      }
  }
  
  private void scanfinger_getID(JSONArray args, CallbackContext callbackContext) throws JSONException {
      String message = args.getString(0);
      JSONObject object = new JSONObject(message);
      String id = object.getString("id");
  
  
      String dev = "/dev/ttySAC3";
      byte[] devName = dev.getBytes();
      fd = SFM_Init(devName);
  
  
      callbackContext.success("Got to scanfinger_getID: " + id);
  
  }
  </code></pre>
  
  <p>}</p>