【问题标题】:Rendering error android studio渲染错误android studio
【发布时间】:2016-03-08 03:04:58
【问题描述】:

我刚刚将我的 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'
}

【问题讨论】:

  • 你可以查看这个链接stackoverflow.com/questions/18195807/…
  • 你看到我的屏幕截图的圆形指示部分......你能用你安装的 API 级别进行调整
  • 嗨,我调整到 21 或 22 给所有空白(没有任何预览)
  • docs.google.com/document/d/…。这是屏幕截图
  • 最好你需要通过 SDK 管理器安装最新的 buildTool。

标签: android android-studio gradle rendering


【解决方案1】:

根据您的 Manifest 将您在设计器预览中的 android 版本更改为当前版本。渲染问题导致您的设计器预览使用的 API 级别高于您当前的 android API 级别。

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

【讨论】:

  • 感谢您的回复。你能提供更多细节吗?这是我的清单?在我由 android studio 生成的清单中,现在有 android API 级别。 docs.google.com/document/d/…
  • 可以查看这个链接吗stackoverflow.com/questions/18195807/…
  • 我可以看到使用
  • "根据您的 Manifest 将您的设计师预览中的 android 版本更改为当前版本"。怎么办,我的清单文件没有任何版本
  • 我发现使用 appcompatButton 会报错 The following classes could not be instantiated: - android.support.v7.widget.AppCompatButton
猜你喜欢
  • 2020-08-23
  • 2017-09-18
  • 1970-01-01
  • 1970-01-01
  • 2020-07-24
  • 2019-01-25
  • 2018-01-24
  • 1970-01-01
相关资源
最近更新 更多