0

当我更新 gradle 并构建我的项目时,我收到以下错误:

Android resource compilation failed
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:484: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:608: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:608: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:630: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:647: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:667: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:706: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:714: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:714: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:732: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/tools'.


D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:2143: error: invalid resource type 'attr' for parent of style.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:2636: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:2636: error: resource previously defined here.

gradle 2.1.4 没有错误

4

1 回答 1

1

这里有两个问题

首先,查看您的app/src/main/res/values. 其中一个定义了一种样式,并使用一个属性作为该样式的父级:

D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:2143:错误:样式父级的资源类型“attr”无效。

Style 的父母只能是 style。要么完全删除该父级,要么将其更改为另一种样式。

其次,属性 layout_anchorGravity 似乎有两个相互冲突的定义——在您的依赖项或本地值文件中。检查此属性的来源并覆盖它或完全删除它。

于 2018-10-01T16:55:12.523 回答