【发布时间】:2017-02-15 09:20:09
【问题描述】:
我在同步项目时遇到 SrcCompat 错误。我有一个带有数字按钮和 4 个 ImageViews 的相对布局。这是其中一个 ImageView:
<RelativeLayout 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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.bigal.datacollecter_v1.MainActivity">
<ImageView
android:id="@+id/imLogoLL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/arrow_down_float"
android:layout_above="@+id/imRinkL"
android:layout_alignLeft="@+id/imRinkL"/>
.......
这是我的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.bigal.datacollecter_v1"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.0'
这是来自 gradle 控制台输出的 4 个相同错误中的 1 个:
C:\Users\bigal\AndroidStudioProjects\DataCollecter_V1\app\src\main\res\layout\activity_main.xml
Error:(766) No resource identifier found for attribute 'srcCompat' in package 'com.example.bigal.datacollecter_v1'
我尝试过:根据@987654321 将 srcCompat 更改为 src(我收到一个意外的命名空间错误)、将 res-auto 更改为命名空间、更改 acccompat-v7 版本、重新启动、制作项目、使缓存无效、清理等@
我正在尝试以 Lollipop 为目标并最终迁移到 API 23。感谢您的建议!
【问题讨论】:
-
我之前尝试了该链接中的每个建议-更改了 srcCompat、更改了 res-auto、更改了 appcompatv7 版本。没用!
-
您是否将
'com.android.support:appcompat-v7:22.2.0'更新到最新版本?我认为是 22.2.1 -
22.2.1 没有帮助。
-
两年多来我一直没有找到它的回购或历史记录。我认为最接近的来源是android-developers.googleblog.com
标签: android android-studio-2.2