升级Android支持库23.2.0后出现代码分析错误(意外的命名空间前缀)
我升级到Android支持库23.2.0并添加了升级Android支持库23.2.0后出现代码分析错误(意外的命名空间前缀),android,android-support-library,Android,Android Support Library,我升级到Android支持库23.2.0并添加了 vectorDrawables.useSupportLibrary = true 到我的build.gradle,这样我就可以支持低于21的API。(详情请参见) 我也换了 android:src="@drawable/ic_create_black_24dp" 与 在每个使用矢量绘图的Imageview中 该应用程序编译和运行都非常好,但代码分析报告: 错误:(56,9)为标记ImageView 为什么会这样?尽管我有错误,为什么它仍在编译
vectorDrawables.useSupportLibrary = true
到我的build.gradle,这样我就可以支持低于21的API。(详情请参见)
我也换了
android:src="@drawable/ic_create_black_24dp"
与
在每个使用矢量绘图的Imageview中
该应用程序编译和运行都非常好,但代码分析报告:
错误:(56,9)为标记ImageView
为什么会这样?尽管我有错误,为什么它仍在编译
编辑:我添加了
xmlns:app="http://schemas.android.com/apk/res-auto"
在我的根布局中。需要将此添加到顶部父布局中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
将xmlns:app=“schemas.android.com/apk/res auto”
作为属性添加到您的图像视图
或顶级
标签,如线性布局
,协调布局
,相对布局
。。等
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_create_black_24dp"
xmlns:app="http://schemas.android.com/apk/res-auto"/>
或在父布局中
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"/>
Lint,Android的代码分析工具,似乎还不知道支持向量绘图功能。通过将tools:ignore=“MissingPrefix”
添加到ImageView
标记,您可以安全地忽略此错误。您看到了此错误,因为原始ImageView没有srcCompat属性。此属性仅由AppCompatImageView使用,它是注入的,而不是您声明的ImageView。使用过载视图充气器时,很容易发现此错误。Lint执行静态分析,不知道如何从代码中使用xml进行攻击。将xml中的ImageView更改为android.support.v7.widget.AppCompatImageView同步渐变尝试运行。另外,添加工具:src=“@drawable/ic_create_black_24dp”
以预览布局中的可绘制内容。请在您的回答中也提到这一行xmlns:tools=“”
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"/>