So today with some help from the people on here I put together a simple android app that uses the ndk. I imported the eigen library right into the jni folder that I created in the source tree and then using cygwin I was able to compile the project. Heres the source so other people trying to learn jni basics passing data back and forth from c++ to java and back have some code to go by. The app just takes 6 numbers in edittext fields and when the user clicks the button two float arrays are passed to the native method and loaded into two eigen float vectors where they are then added together. The product of the two vectors is passed back to java and then displayed in a textview.
Heres a link to the eigen library for android:
https://bitbucket.org/erublee/eigen-android
You just need the actual eigen folder which is one layer down in the file tree. Just copy and paste the eigen folder thats one layer into the eigen source and place inside the jni folder that you create to hold your c++ code in your android project.
Heres the java:
package jnimath.act;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class JnimathActivity extends Activity {
/** Called when the activity is first created. */
public EditText x;
public EditText y;
public EditText z;
public EditText x2;
public EditText y2;
public EditText z2;
public float[] vecArray;
public TextView textView1;
public Button run;
float[] array3 = new float[3];
float[] array1 = new float[3];
float[] array2 = new float[3];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
x = (EditText)findViewById(R.id.x);
y = (EditText)findViewById(R.id.y);
z = (EditText)findViewById(R.id.z);