Crash in AlertDialog builder when android suport library updated to 24

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

The code was working fine before, but when I updated support library to 24, It crashes when displaying alert dialog. Couldn't find any help as it is updated recently.

Code:

AlertDialog.Builder builderSingle; builderSingle = new AlertDialog.Builder(mContext); //set buttons and title code builderSingle.show(); 

Logcat:

And the support libraries are:

    compile('com.android.support:recyclerview-v7:24.0.0') {         exclude group: 'com.android.support', module: 'support-v4'     }     compile('com.android.support:support-v4:24.0.0') {         force = true     }     compile 'com.android.support:appcompat-v7:24.0.0'     compile 'com.android.support:design:24.0.0' 

回答1:

I think there is some problem with your imports.

The Exception :

java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.DialogTitle" 

says it is unable to find DialogTitle but i am not seeing DialogTitle any where in your code.

So if you are having any import called android.support.v7.internal.widget.DialogTitle any where in your project then remove it.

You need to import this for your AlertDialog:

 import android.app.AlertDialog; 

instead of this:

 import android.support.v7.app.AlertDialog;  


回答2:

Import this:

import android.app.AlertDialog;



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!