0

java.lang.NoClassDefFoundError: android/support/v4/app/NotificationCompat$Builder

I know this error is resolved by adding private libraries to project, but in my case if I add private libraries then I am getting different error:

Unable to execute dex: Multiple dex files define

And the fix for above was removing private libraries which I found here

So any better solution???

My code:

private void check() {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            getApplicationContext());
    Notification notification = builder.setSmallIcon(R.drawable.icon)
            .setContentTitle("New notification")
            .setContentText("Hello world!").build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, notification);
}

My project build path :

enter image description here

Community
  • 1
  • 1
Niraj Chauhan
  • 7,677
  • 12
  • 46
  • 78

1 Answers1

0

I think you have added two similar libraries to your project . Go to project properties ->java Build Path->libraries

AndroidLad
  • 687
  • 7
  • 14