我的布局检查器中出现未知错误。如果我的应用程序在模拟器下运行时根本不加载布局,那将不是问题。我正在使用带有支持库 26.0.0-beta2 的安卓 O。Gradle 未发现任何错误。这是日志:
Rendering failed with a known bug. Please try a rebuild. The following classes could not be instantiated:
- android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.AppCompatTextView (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.NoSuchFieldError: ViewBackgroundHelper at android.support.v7.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:46) at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:73) `at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:66) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70) at android.view.LayoutInflater.rInflate(LayoutInflater.java:834) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:95) at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:52) at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:46) at com.android.layoutlib.bridge.impl.Layout.createNavBar(Layout.java:284) at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:140) Copy stack to clipboard`
我尝试重建,刷新,清除缓存,更改整个布局的代码。我觉得问题不在于布局的xml,因为我也尝试从教程站点复制布局。同样的问题。
将
支持库更改为 26 alpha,问题已解决