4

I want to do exactly, what he does: Android Notification at time But in my AlarmReceiver class, I have an error: The method build() is undefined for the type NotificationCompat.Builder, at line: mNotificationManager.notify(1, mBuilder.build());

In android developer site is a similar code, but the same error appears(http://developer.android.com/training/notify-user/build-notification.html).

Any help is greatly appreciated.

Community
  • 1
  • 1
mate1229
  • 95
  • 1
  • 7

2 Answers2

10

You may be on an older version of the Android Support package. Make sure that your project has a current copy of android-support-v4.jar or android-support-v13.jar in libs/.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • or use new NotificationCompat.Builder(context) for target >= Honeycomb as mentioned in another question! – sjkm Dec 10 '15 at 13:58
4

It appears that there's a broken version of the Android Support package out there. Specifically, the one currently being deployed in ActionBarSherlock.

I'd recommend always using the latest android-support-v4.jar from inside the Android SDK. You'll find it in [android-sdk]/extras/android/support/v4.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • Ran into this issue too after downgrading v4 support to match ActionBarSherlock - sigh... – Norman H Aug 18 '15 at 15:42
  • 1
    This is a very old answer; I thoroughly encourage you to stop using ActionBarSherlock in favor of the support library. – Paul Lammertsma Aug 18 '15 at 16:31
  • This looks like a promising article on the topic: http://www.grokkingandroid.com/migrating-actionbarsherlock-actionbarcompat/ – Norman H Aug 18 '15 at 18:27
  • Yes, it is! Nice to see some love for @WolframRittmeyer! – Paul Lammertsma Aug 18 '15 at 20:45
  • Looks like this SO item is another relevant resource: http://stackoverflow.com/questions/20933944/what-are-the-common-issues-when-migrating-from-actionbarsherlock-to-actionbarcom – Norman H Aug 18 '15 at 21:07