android - 渲染错误android studio

标签 android android-studio gradle rendering

我刚刚将我的 android studio 更新到最新版本 1.5.1,但它在预览布局 xml 文件时不断出错(即使在打开新项目时)。我正在使用 android API 23 进行预览。非常感谢任何帮助。谢谢

 Rendering Problems The following classes could not be instantiated:
- android.support.design.widget.FloatingActionButton (Open Class, Show Exception, Clear Cache)

我的布局文件(这是android studio自动生成的)

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.vic.test2.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "com.example.vic.test2"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
}

最佳答案

enter image description here根据您的 list 将设计器预览中的 android 版本更改为当前版本。渲染问题导致您的设计器预览使用比当前 Android API 级别更高的 API 级别。

根据您当前的 API 级别进行调整。如果 API 级别不在列表中,则需要通过 SDK Mangager 安装它。

关于android - 渲染错误android studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35858165/

相关文章:

ubuntu - 在 ubuntu 15.04 上安装 android studio 期间无法运行 mksdcard 工具

grails - 如何将 mongodb 和/或 postgresql-extension 插件添加到 Grails 3.0.0+ 中?

gradle - Sonarqube gradle 分析项目,在根项目中找不到任务

android - 文本大小不会因不同的屏幕布局而改变?

android - TextWatcher 用于多个 EditText

android - 如何在Android Studio中找到gradle插件的所有可用属性和方法?

java - 无法使用 HashMap 替换方法 : call require api level 24 (current min is 22):java. util.HashMap#replace

android-studio - 如何在 Android Studio 中使用 BoofCV?

java - 您如何以编程方式访问已解决的实现依赖项?

android - 将位图设置为背景并裁剪它