之前代码运行正常,但是当我将支持库更新到24时,它在显示警告对话框时崩溃了。 由于最近更新了,无法找到任何帮助。
代码:
AlertDialog.Builder builderSingle;
builderSingle = new AlertDialog.Builder(mContext);
//set buttons and title code
builderSingle.show();
logcat的:
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.DialogTitle" on path: DexPathList[[zip file "/data/app/com.abc-2/base.apk"],nativeLibraryDirectories=[/data/app/com.abc-2/lib/arm, /data/app/com.abc-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:583)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:80)
at android.support.v7.app.AlertController.installContent(AlertController.java:214)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:953)
at qi.mnav.search.fragments.RecentsFavouriteFragment.handleFavLongClick(RecentsFavouriteFragment.java:525)
at qi.mnav.search.fragments.RecentsFavouriteFragment.onItemLongClick(RecentsFavouriteFragment.java:353)
at android.widget.AbsListView.performLongPress(AbsListView.java:3134)
at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:3066)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Suppressed: java.lang.ClassNotFoundException: android.support.v7.internal.widget.DialogTitle
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 31 more
支持库是:
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'
答案 0 :(得分:1)
我认为您的导入存在问题。
例外:
java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.DialogTitle"
表示无法找到DialogTitle
,但我没有看到DialogTitle
代码中的任何位置。
因此,如果您在项目的任何位置进行任何名为android.support.v7.internal.widget.DialogTitle
的导入,请将其删除。
您需要为AlertDialog导入此内容:
import android.app.AlertDialog;
而不是:
import android.support.v7.app.AlertDialog;
答案 1 :(得分:0)
导入此内容:
import android.app.AlertDialog;