Android studio创建项目后xml文件无法预览并报错如下
Failed to load AppCompat ActionBar with unknown error.
The following classes could not be instantiated:
- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)
- android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard
根据错误应该是v7的包错误了,百度之后并没有什么特别有效的方法去修改
自己试了半天之后,发现可以正常显示了,首先打开open model settings,选到app ------的dependencies
将图中画圈的修改了,并把默认constraint包删除重新添加,可能会报默认sdk版本过低的错误,在build.gradle中将版本修改之后等项目重新加载完成之后问题应该就解决了。
希望会有更好的方法啦改正这个错误,不知道是不是版本的问题。