【问题标题】:Rendering Problems The following classes could not be found - android.support.v7.widget.AppCompatTextView渲染问题找不到以下类 - android.support.v7.widget.AppCompatTextView
【发布时间】:2016-10-28 05:26:52
【问题描述】:

我是 Android Studio 的新手。我的项目正在运行和执行,但每当我点击activity_main.xml 时,我都会看到我不理解的错误。错误是

  Rendering Problems The following classes could not be found:
- android.support.v7.widget.AppCompatTextView (Fix Build Path, Edit XML, Create Class)

我的activity_main.xml 是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"     
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#5b9bd5">



<ImageButton
    android:id="@+id/regiterbutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/registerbutton"

    android:layout_marginBottom="67dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

<ImageButton
    android:id="@+id/loginbutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/loginbutton"

    android:layout_above="@+id/regiterbutton"
    android:layout_alignLeft="@+id/regiterbutton"
    android:layout_alignStart="@+id/regiterbutton"
    android:layout_marginBottom="50dp" />
</RelativeLayout>

我的 AndroidManifest.xml 是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.jawadrauf.ratingapp" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="16"
    tools:overrideLibrary="com.facebook" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<!-- Connect to Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

我的 build.gradle 是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 17
    buildToolsVersion '19.1.0'

defaultConfig {
    applicationId "com.example.jawadrauf.ratingapp"
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt')
        ,        'proguard-rules.pro'
      }
    }
  }

 repositories {
 // You can also use jcenter if you prefer
 mavenCentral()
  }
 dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.facebook.android:facebook-android-sdk:4.5.0'
 compile 'com.android.support:appcompat-v7:20.0.0'

 }

【问题讨论】:

  • 发布完整的activity_main.xml 文件

标签: android xml android-layout android-studio textview


【解决方案1】:

AppCompatTextView 被添加到appcompat-v7:22.1.0 中,appcompat-v7 的最新版本是24.0.0。您在 gradle 文件中使用的是非常旧的版本 20.0.0

您必须使用

更新您的 gradle 文件
compile 'com.android.support:appcompat-v7:24.0.0'

并确保您已在 SKD Manager 中安装了所有更新,包括最新版本的支持库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-05
    • 1970-01-01
    • 2015-05-25
    • 2018-04-16
    • 2018-02-02
    • 2016-02-23
    相关资源
    最近更新 更多