title: how to call Calendar.getInstance in NDK using C++?
body: <p>I have looked but can not find the answer to this, I am trying to instantiate a Calendar object in C++ using the NDK. I have tried using both AllocObject and NewObject, both yield the same result.</p>
  
  <p>Here is my Java code</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private final static String TAG = "TestJNIConstructor";
  private native Calendar getCalendarObject();
  
  static
  {
      System.loadLibrary("myjni");
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      Calendar cal = getCalendarObject();
      Log.d(TAG, "cal = " + cal.toString());
  }
  </code></pre>
  
  <p>and here is my C++ code </p>
  
  <pre><code>#include "TestJNIConstructor.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  JNIEXPORT jobject JNICALL Java_com_example_testjniconstructor_MainActivity_getCalendarObject(JNIEnv *env, jobject thisObj)
  {
      jclass cls = env-&gt;FindClass("java/util/Calendar");
  
      jmethodID midInit = env-&gt;GetMethodID(cls, "getInstance", "()Ljava/util/Calendar");
      if(NULL==midInit)
      {
          return NULL;
      }
      //jobject newObj = env-&gt;NewObject(cls, midInit);
      jobject newObj = env-&gt;AllocObject(cls);
      return newObj;
  
  
  }
  </code></pre>
  
  <p>and the .h</p>
  
  <pre><code>#include &lt;jni.h&gt;
  
      extern "C" {
          JNIEXPORT jobject JNICALL Java_com_example_testjniconstructor_MainActivity_getCalendarObject(JNIEnv *env, jobject thisObj);
      }
  </code></pre>
  
  <p>the error I get is:</p>
  
  <p>04-14 16:16:09.255: E/AndroidRuntime(10678): FATAL EXCEPTION: main
  04-14 16:16:09.255: E/AndroidRuntime(10678): java.lang.NoSuchMethodError: no method with name='getInstance' signature='()Ljava/util/Calendar' in class Ljava/util/Calendar;
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at com.example.testjniconstructor.MainActivity.getCalendarObject(Native Method)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at com.example.testjniconstructor.MainActivity.onCreate(MainActivity.java:33)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.Activity.performCreate(Activity.java:4465)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.ActivityThread.access$600(ActivityThread.java:128)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.os.Handler.dispatchMessage(Handler.java:99)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.os.Looper.loop(Looper.java:137)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at android.app.ActivityThread.main(ActivityThread.java:4514)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at java.lang.reflect.Method.invoke(Method.java:511)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
  04-14 16:16:09.255: E/AndroidRuntime(10678):    at dalvik.system.NativeStart.main(Native Method)</p>
  
  <p>any help would be greatly appreciated.</p>