当我更新gradle并构建我的项目时,出现以下错误:
Android resource compilation failed
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:484: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:608: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:608: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:630: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:647: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:667: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:706: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:714: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:714: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/apk/res-auto'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:732: warn: ignoring element 'g' with unknown namespace 'http://schemas.android.com/tools'.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:2143: error: invalid resource type 'attr' for parent of style.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:2636: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
D:MyAndroidAppMyApp2MyAppbuildintermediatesincrementalmergeWithAnalyticsDebugResourcesmerged.dirvaluesvalues.xml:2636: error: resource previously defined here.
gradle 2.1.4 没有错误
这里有两个问题
首先,浏览app/src/main/res/values
下的文件。其中一个定义一个样式,并使用属性作为该样式的父级:
D:\MyAndroidApp\MyApp2\MyApp\build\intermediates\incremental\mergeWithAnalyticsDebugResources\merged.dir\values\values.xml:2143:错误:样式父级的资源类型"attr"无效。
Style的父母只能是Style。完全删除该父样式或将其更改为其他样式。
其次,属性layout_anchorGravity似乎有两个相互冲突的定义 - 在您的依赖项或本地值文件中。检查此属性的来源,然后覆盖它或完全删除它。