Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
升级Android支持库23.2.0后出现代码分析错误(意外的命名空间前缀)_Android_Android Support Library - Fatal编程技术网

升级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 为什么会这样?尽管我有错误,为什么它仍在编译

我升级到Android支持库23.2.0并添加了

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"/>