首次使用导航抽屉活动, 在新打开的项目中显示这些错误
Failed to find style 'coordinatorLayoutStyle' in current theme
和
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (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.
......
答案 0 :(得分:0)
在build.gradle(模块)实现'com.android.support:appcompat-v7:28.0.0-alpha3'中将alpha 3更改为alpha 1。
答案 1 :(得分:0)
在AndroidManifest.xml中检查您的主题
并在主题中的values / styles.xml中添加coordinatorLayoutStyle
<item name="coordinatorLayoutStyle">@style/Widget.Design.CoordinatorLayout</item>
答案 2 :(得分:0)
查看应用程序级别gradle文件中的依赖项
implementation 'com.android.support:appcompat-v7:27.1.1'
这可以为您服务。还记得在项目级别的gradle文件中添加google()
,有关here
您还可以在values文件夹中查看样式文件,声明样式的地方应该像这样
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>