katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.76k forks source link

App crashes when setting a notification on Android 2.2 #49

Closed ianjamieson closed 10 years ago

ianjamieson commented 10 years ago

When a notification is set on Android 2.2 the application force closes. This is immediately after calling:

window.plugin.notification.local.add();

In Eclipse I can see this error:

01-07 09:26:31.015: E/dalvikvm(8751): Could not find class 'android.app.Notification$Builder', referenced from method de.appplant.cordova.plugin.localnotification.Receiver.buildNotification

Here is the whole error report:

01-07 09:26:31.015: E/dalvikvm(8751): Could not find class 'android.app.Notification$Builder', referenced from method de.appplant.cordova.plugin.localnotification.Receiver.buildNotification
01-07 09:26:31.015: D/MobileDataStateTracker(1339): replacing old mInterfaceName (rmnet0) with rmnet0 for supl
01-07 09:26:31.015: W/dalvikvm(8751): VFY: unable to resolve new-instance 18 (Landroid/app/Notification$Builder;) in Lde/appplant/cordova/plugin/localnotification/Receiver;
01-07 09:26:31.015: D/dalvikvm(8751): VFY: replacing opcode 0x22 at 0x0000
01-07 09:26:31.025: D/dalvikvm(8751): VFY: dead code 0x0002-0046 in Lde/appplant/cordova/plugin/localnotification/Receiver;.buildNotification ()Landroid/app/Notification$Builder;
01-07 09:26:31.025: I/dalvikvm(8751): Could not find method android.app.Notification$Builder.setContentIntent, referenced from method de.appplant.cordova.plugin.localnotification.Receiver.setClickEvent
01-07 09:26:31.025: W/dalvikvm(8751): VFY: unable to resolve virtual method 69: Landroid/app/Notification$Builder;.setContentIntent (Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;
01-07 09:26:31.025: D/dalvikvm(8751): VFY: replacing opcode 0x6e at 0x0030
01-07 09:26:31.025: D/dalvikvm(8751): VFY: dead code 0x0033-0034 in Lde/appplant/cordova/plugin/localnotification/Receiver;.setClickEvent (Landroid/app/Notification$Builder;)Landroid/app/Notification$Builder;
01-07 09:26:31.025: I/dalvikvm(8751): Could not find method android.app.Notification$Builder.getNotification, referenced from method de.appplant.cordova.plugin.localnotification.Receiver.showNotification
01-07 09:26:31.025: W/dalvikvm(8751): VFY: unable to resolve virtual method 68: Landroid/app/Notification$Builder;.getNotification ()Landroid/app/Notification;
01-07 09:26:31.035: D/dalvikvm(8751): VFY: replacing opcode 0x6e at 0x001b
01-07 09:26:31.035: I/dalvikvm(8751): Could not find method android.app.Notification$Builder.build, referenced from method de.appplant.cordova.plugin.localnotification.Receiver.showNotification
01-07 09:26:31.035: W/dalvikvm(8751): VFY: unable to resolve virtual method 67: Landroid/app/Notification$Builder;.build ()Landroid/app/Notification;
01-07 09:26:31.035: D/dalvikvm(8751): VFY: replacing opcode 0x6e at 0x0029
01-07 09:26:31.035: D/dalvikvm(8751): VFY: dead code 0x001e-0021 in Lde/appplant/cordova/plugin/localnotification/Receiver;.showNotification (Landroid/app/Notification$Builder;)V
01-07 09:26:31.035: D/dalvikvm(8751): VFY: dead code 0x002c-0030 in Lde/appplant/cordova/plugin/localnotification/Receiver;.showNotification (Landroid/app/Notification$Builder;)V
katzer commented 10 years ago

Android is only supported with SDK >= 11 (Android 3.0 and above).

peterholak commented 10 years ago

I see you're using the android.app.Notification.Builder class from API 11, which could be replaced by android.support.v4.app.NotificationCompat.Builder from the Android Support Library to add support for older versions without limiting any features. Only problem would be that using the support library increases the resulting .apk size by about 200kb.

jonbarlo commented 10 years ago

Thanks it seems i was trying to test one phonegap app (cordova 3.4.x) with a very old phone (with very old Android OS i didnt noticed 'til i found this post) with that said i updated the OS and also change of device and both worked just fine.

Cheers buddy