2017-05-08 127 views
0

因此,我遇到了这个问题。这是摇篮建立控制台输出:任务'app:process:DebugResources'的执行失败

https://i.stack.imgur.com/YxvfR.png

我查了一些帖子在网上(主要是SO)。到目前为止,我已经更改了buildToolsVersion(它不会让我低于25.0.0),干净构建,重新启动,检查所有XML文件的问题。

没有解决它。我也没有发现任何关于前几个错误的信息(“没有资源匹配......”)。我试图改变这些文件来删除这些行,但1)“他们不是项目的一部分”2)如果我改变了还有另一个错误。

我也回到了我的代码的以前的版本,它的工作,并以某种方式现在他们都显示相同的错误。

您能否指点我正确的方向?我想了解什么是错的,我该如何解决这个问题?

[更新]

下面是res\layout\abc_list_menu_item_layout.xml代码:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.view.menu.ListMenuItemView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/listPreferredItemHeightSmall"> 

<!-- Icon will be inserted here. --> 

<!-- The title and summary have some gap between them, and this 'group' should be centered vertically. --> 
<RelativeLayout 
     android:layout_width="0dip" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:layout_marginLeft="?attr/listPreferredItemPaddingLeft" 
     android:layout_marginRight="?attr/listPreferredItemPaddingRight" 
     android:duplicateParentState="true"> 

    <TextView 
     android:id="@+id/scale" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:textAppearance="?attr/textAppearanceListItemSmall" 
     android:singleLine="true" 
     android:duplicateParentState="true" 
     android:ellipsize="marquee" 
     android:fadingEdge="horizontal" /> 

    <TextView 
     android:id="@+id/shortcut" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/title" 
     android:layout_alignParentLeft="true" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:singleLine="true" 
     android:duplicateParentState="true" /> 

</RelativeLayout> 

<!-- Checkbox, and/or radio button will be inserted here. --> 

而且这一个对res\layout\abc_popup_menu_item_layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.view.menu.ListMenuItemView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/dropdownListPreferredItemHeight" 
    android:minWidth="196dip" 
    style="@style/RtlOverlay.Widget.AppCompat.PopupMenuItem"> 

<!-- Icon will be inserted here. --> 

<!-- The title and summary have some gap between them, and this 'group' should be centered vertically. --> 
<RelativeLayout 
     android:layout_width="0dip" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:duplicateParentState="true" 
     style="@style/RtlOverlay.Widget.AppCompat.PopupMenuItem.InternalGroup"> 

    <TextView 
      android:id="@+id/scale" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:textAppearance="?attr/textAppearanceLargePopupMenu" 
      android:singleLine="true" 
      android:duplicateParentState="true" 
      android:ellipsize="marquee" 
      android:fadingEdge="horizontal" 
      style="@style/RtlOverlay.Widget.AppCompat.PopupMenuItem.Text" /> 

    <TextView 
      android:id="@+id/shortcut" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/title" 
      android:textAppearance="?attr/textAppearanceSmallPopupMenu" 
      android:singleLine="true" 
      android:duplicateParentState="true" 
      style="@style/RtlOverlay.Widget.AppCompat.PopupMenuItem.Text" /> 

</RelativeLayout> 

<ImageView 
     android:id="@+id/submenuarrow" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginStart="8dp" 
     android:layout_marginLeft="8dp" 
     android:scaleType="center" 
     android:visibility="gone" /> 

<!-- Checkbox, and/or radio button will be inserted here. --> 

这两个与res\merged\debug\SAME_NAME的区别是线路xmlns:android="http://schemas.android.com/apk/res/android"上的错误,表示URI未注册。由于这两个文件都是自动创建的,所以我不知道发生了什么。我搜索了最后一个“未注册的URI”错误,但所提供的所有解决方案都非常不同,似乎对某个项目非常具体,以至于它们似乎并不适用于此。我尝试使用Build Variant“release”,然后将其更改回去,但没有再发生任何事情。

+0

你可以发布文件“res/layout/abc_list_menu_item_layout.xml”。此外,你有多个版本的文件(可能在不同的“res/layout-?”目录中? 看起来布局引用了未定义的视图ID。 – AndroidGuy

+0

@AndroidGuy感谢提示我已经编辑了这个问题来展示代码,并进一步解释了我所遇到的情况,在使用Build Variant“release”之后,除了现在没有重复的东西,我注意到两个文件在build-cache如果我使它无效并重新启动,它应该工作吗?干杯! – ruiBarbs

+0

回答我自己,无效/重新启动缓存不起作用。 – ruiBarbs

回答

0

现在,我终于得到这个工作,但根本不知道为什么或如何开始工作。所以我在我的一个布局中使用了这个ListView,并且我想在其他布局中添加另一个ListView。出于某种原因,当我创建第二个时,它更改了第一个的ID(其中一个是“标题”)。

我删除了两个ListViews,但问题仍然存在。所以当我意识到我有一个'title'id的ListView时,我决定再次用第一个ID来做,现在一切正常。

几个问题:

  1. 为什么第二的ListView改变了第一的证书? - 我为ListViews创建了一个布局,并且分离了适配器,因为我想以不同的方式展示它们。

  2. 为什么删除布局和适配器一开始并未解决问题?

另外,我还有一个问题是相关的。当我按下工具栏上的3dots(溢出)时,应用程序崩溃。它在ListMenuItemView引发一个NullPointerException。当我去问题中的错误文件之一时,它说它Cannot find the declaration of android.support.v7.view.menu.ListMenuItemView ...有什么想法吗?

0

这对我来说也是一片蓝色。我正在关注为什么发生这种情况,但解决方案是清除构建缓存。 要执行任务,请选择查看>工具的Windows>从菜单栏中终端并使用以下命令之一:

对于Windows:

 gradlew cleanBuildCache
对于Mac或Linux:
 ./gradlew cleanBuildCache

以供将来参考和相关选项,看看这个链接: Clear the build cache

相关问题