app crash after phonegap update

1,127 views
Skip to first unread message

hellionweb

unread,
Jan 7, 2011, 3:12:35 AM1/7/11
to phonegap
Hi!

After update to phonegap-0.9.3 this doesn't work

MyToaster toaster = new MyToaster(this, appView);
appView.addJavascriptInterface(toaster, "MyToaster");

especially the second line - it breaks the code

my error log:

01-07 10:09:36.476: ERROR/AndroidRuntime(19910): FATAL EXCEPTION: main
01-07 10:09:36.476: ERROR/AndroidRuntime(19910):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.phonegap.hellophone/com.phonegap.hellophone.App}:
java.lang.NullPointerException
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2781)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2797)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread.access$2300(ActivityThread.java:135)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.os.Handler.dispatchMessage(Handler.java:99)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.os.Looper.loop(Looper.java:143)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread.main(ActivityThread.java:4914)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
java.lang.reflect.Method.invokeNative(Native Method)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
java.lang.reflect.Method.invoke(Method.java:521)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:858)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
dalvik.system.NativeStart.main(Native Method)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): Caused by:
java.lang.NullPointerException
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
com.phonegap.hellophone.App.onCreate(App.java:28)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1065)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2745)
01-07 10:09:36.476: ERROR/AndroidRuntime(19910): ... 11 more


Felix Mueller

unread,
Jan 10, 2011, 9:22:13 AM1/10/11
to phonegap
Hi there

I have the same issue.

Felix

Felix Mueller

unread,
Jan 11, 2011, 4:22:18 AM1/11/11
to phonegap
Hi there

I think I found the cause for the crash - appView is not inititalized.
If you look at the example at the top in DroidGap.java you see that
one needs to call 'super.init()' after calling
'super.onCreate()' (seems to be new as of 0.9.3).

* public class Examples extends DroidGap {
* @Override
* public void onCreate(Bundle savedInstanceState) {
* super.onCreate(savedInstanceState);
*
* // Set properties for activity
* super.setProperty("loadingDialog", "Title,Message"); //
show loading dialog
* super.setProperty("errorUrl", "file:///android_asset/www/
error.html"); // if error loading file in super.loadUrl().
*
* // Initialize activity
* super.init();

Cheers
Felix

hellionweb

unread,
Jan 11, 2011, 1:09:15 PM1/11/11
to phonegap
Thank you very much!

Cheers!
V.
Reply all
Reply to author
Forward
0 new messages