2013-07-16 238 views
3

添加我的應用程序到Google Play,但我得到的通知bulider有些崩潰, 這是暴跌的消息

java.lang.NoClassDefFoundError: android.app.Notification$Builder 

,這我通知創建代碼,

public void CreateNtf(String text) 
{ 

    Notification notificationView; 
    PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this,0,getIntent(),Intent.FLAG_ACTIVITY_NEW_TASK); 
    if(Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 15){ 

     notificationView = new Notification.Builder(context) 
     .setContentTitle(getResources().getString(R.string.app_name)) 
     .setContentText(text) 
     //.setTicker(getResources().getString(R.string.app_name) + " " + text) 
     .setWhen(System.currentTimeMillis()) 
     .setContentIntent(pendingIntent) 
     //.setDefaults(Notification.DEFAULT_SOUND) 
     .setAutoCancel(false) 
     .setSmallIcon(R.drawable.ic_launcher) 
     .getNotification(); 
    }else{ 
      notificationView = new Notification.Builder(context) 
      .setContentTitle(getResources().getString(R.string.app_name)) 
      .setContentText(text) 
      //.setTicker(getResources().getString(R.string.app_name) + " " + text) 
      .setWhen(System.currentTimeMillis()) 
      .setContentIntent(pendingIntent) 
      //.setDefaults(Notification.DEFAULT_SOUND) 
      .setAutoCancel(false) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .build(); 

    } 
    notificationView.flags |= Notification.FLAG_NO_CLEAR; 
    notificationView.flags |= Notification.FLAG_ONGOING_EVENT; 
    notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 
    notificationManager.notify(1, notificationView); 




} 

所以,我怎麼能解決這個問題嗎? 我仍然得到谷歌的錯誤和崩潰起到

+0

顯然你是在你的if塊之外聲明你的Notification.Builder。 – njzk2

回答