VM Crash when call java function from js using phonegap api
<p>I had using phonegap to program one apps that try to call java function from the java script in the android 2.3.3 environment. </p>

<p>My problem was the the app show alert message and then crash and prompted error message below </p>

<pre><code>    08-04 11:06:12.669: W/dalvikvm(551): JNI WARNING: jarray 0x40522898 points to non-array object (Ljava/lang/String;)
    08-04 11:06:12.669: I/dalvikvm(551): "WebViewCoreThread" prio=5 tid=9 NATIVE
    08-04 11:06:12.669: I/dalvikvm(551):   | group="main" sCount=0 dsCount=0 obj=0x4051dd20 self=0x2a6d88
    08-04 11:06:12.669: I/dalvikvm(551):   | sysTid=559 nice=0 sched=0/0 cgrp=default handle=2780864
    08-04 11:06:12.669: I/dalvikvm(551):   | schedstat=( 943171212 746714576 110 )
    08-04 11:06:12.680: I/dalvikvm(551):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.webkit.WebViewCore.access$3300(WebViewCore.java:53)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.os.Handler.dispatchMessage(Handler.java:99)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.os.Looper.loop(Looper.java:123)
    08-04 11:06:12.680: I/dalvikvm(551):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
    08-04 11:06:12.680: I/dalvikvm(551):   at java.lang.Thread.run(Thread.java:1019)
    08-04 11:06:12.680: E/dalvikvm(551): VM aborting
</code></pre>

<p>Can anyone help/advice on this issue?</p>

<p>Below is the code   </p>

<pre><code> MainActivity.java

        import org.apache.cordova.*;

        import android.os.Bundle;
        import android.app.Activity;
        import android.view.Menu;
        import android.view.MenuItem;
        import android.support.v4.app.NavUtils;

        public class MainActivity extends DroidGap {
            private MyClass mc;

            @Override
            public void onCreate(Bundle savedInstanceState) {       

                super.onCreate(savedInstanceState);
                super.init(); 
                mc = new MyClass(this, appView);
                appView.addJavascriptInterface(mc, "MyCls");       
                super.loadUrl("file:///android_asset/www/5.html");
            }  

        }


    MyClass.java

        import org.apache.cordova.DroidGap;

        import android.content.Context;
        import android.telephony.TelephonyManager;
        import android.webkit.WebView;

        public class MyClass {
              private WebView mAppView;
              private DroidGap mGap;

              public MyClass(DroidGap gap, WebView view)
              {
                mAppView = view;
                mGap = gap;
                System.out.println("jjjjj");
              }

              public String getTelephoneNumber(){
                  return "i am android";
              }
            }

    5.html
    &lt;!DOCTYPE html&gt;
    &lt;html lang="en"&gt;
    &lt;head&gt;
        &lt;meta charset="UTF-8"&gt;      
        &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
        &lt;script src="jquery.jsonp.js"&gt;&lt;/script&gt;
    &lt;/head&gt;

    &lt;script&gt;
    $(document).ready(function(){

        $("#c2").click(function(){
            alert('jjjj');
            var t = window.MyCls.getTelephoneNumber();
            alert(t );
        });
    });
    &lt;/script&gt;

    &lt;body&gt;
    &lt;br&gt;&lt;button id="c2"&gt;Call Android Activity&lt;/button&gt;
    &lt;/body&gt;
    &lt;/html&gt;

    Manifest:

    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myfirstapp"
        android:versionCode="1"
        android:versionName="1.0" &gt;

        &lt;uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" /&gt;

        &lt;supports-screens 
        android:largeScreens="true" 
        android:normalScreens="true" 
        android:smallScreens="true" 
        android:resizeable="true" 
        android:anyDensity="true" /&gt;
    &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
    &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
    &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
    &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
    &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; 
    &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
    &lt;uses-permission android:name="android.permission.BROADCAST_STICKY" /&gt;

        &lt;application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" &gt;
            &lt;activity
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:name=".MainActivity"
                android:label="@string/title_activity_main" &gt;
                &lt;meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value="MainActivity" /&gt;
                &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;

            &lt;/activity&gt;
        &lt;/application&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;/manifest&gt;
</code></pre>
