title: jni - convert int[][] to jobjectArray and return it to java
body: <p>I want to create a new array in c holding original array doubled. this is my c code, It compiles but the app crashes:</p>
  
  <pre><code> #include &lt;jni.h&gt;
      JNIEXPORT jobjectArray JNICALL Java_com_example_jninew_MainActivity_getNum(JNIEnv *env, jobject obj, jintArray arr)
      {
        int i,j, sum = 0;
        jsize width = (*env)-&gt;GetArrayLength(env, arr);
        int array[2][2];
         for (i=0; i&lt;width; i++){
  
              jintArray *line =   (*env)-&gt;GetObjectArrayElement(env, arr, i);
              int height =       (*env)-&gt;GetArrayLength(env, line);
              jint *pos = (*env)-&gt;GetIntArrayElements(env, line, 0);
              for (j=0; j&lt;height; j++){
                     array[i][j] = 2*pos[j];
                }
              (*env)-&gt;ReleaseIntArrayElements(env, arr, pos, 0);
         }
  
  
           return array;
      }
  </code></pre>
  
  <p>Main java code:</p>
  
  <pre><code>package com.example.jninew;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          TextView textView = (TextView) findViewById(R.id.tv);
          int[][] a = {{1,2},{3,55}};
          a = getNum(a);
          textView.setText("G"+a[0][1]);
  
  
      }
      static{
          System.loadLibrary("getNum");
      }
      native int[][] getNum(int[][] a);
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  
  }
  </code></pre>
  
  <p>Can you help me to return the array to java side? Please I need your help!</p>