热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AndroidStudio-资源条目已经定义。-AndroidStudio-ResourceEntryalreadydefined

AftercompilingmyAndroidapplicationusingtheAndroidStudio(Beta),Ihavethefollowingerror:

After compiling my Android application using the Android Studio (Beta), I have the following error:

在使用Android Studio (Beta)编译我的Android应用程序后,我有以下错误:

Error:error: Resource entry background is already defined.
res\drawable-xhdpi-v4\background.9.png:0: Originally defined here.

This occurred when I had a image file called "background" in my res folder.

这发生在我的res文件夹中有一个名为“background”的图像文件。

I then made a 9 patch version of it and pasted it in the same folder. This meant that there was 2 files with the same name. So I unsurprisingly I had this error.

然后我做了一个9补丁版本,并粘贴在同一个文件夹。这意味着有两个同名的文件。所以我不奇怪我有这个错误。

However I now deleted all instances of the background image file (including the 9 patch version and original image) in my code and layout file and I still have this error.

但是我现在已经删除了我的代码和布局文件中的背景图像文件(包括9个补丁版本和原始图像)的所有实例,我仍然有这个错误。

7 个解决方案

#1


57  

You could try to do one of the following:

你可以试着做以下一件事:

  • Clean and Build or gradle clean build assemble
  • 清洁和建造或分级清洁组装。
  • Invalidate and restart Android Studio
  • 使Android Studio无效并重新启动。

#2


17  

1 Build > Clean Project
2 Build > Rebuild Project

1构建> Clean项目2构建>重建项目。

#3


8  

I am using Android studio and I run exactly into the same issue and none of the answers I found on the web helped me solve the problem, including the previous one. So reading through all details of the error messages and found this lines:

我使用的是Android studio,我也遇到了同样的问题,我在网络上找到的答案都没有帮助我解决问题,包括之前的问题。因此,阅读错误信息的所有细节,并找到这条线:

Error:Execution failed for task ':app:processDebugResources'.

错误:任务执行失败:应用程序:processDebugResources。

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\user\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4W\aapt.exe package -f --no-crunch -I C:\Users\user\AppData\Local\Android\android-studio\sdk\platforms\android-20\android.jar -M C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\manifests\debug\AndroidManifest.xml -S C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\res\debug -A C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\assets\debug -m -J C:\Users\user\AndroidStudioProjects\DartsApp\app\build\generated\source\r\debug -F C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\libs\app-debug.ap_ --debug-mode --custom-package com.dartstransit.dartsapp -0 apk --output-text-symbols C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\symbols\debug

com.android.ide.common.internal.LoggedErrorException:未能运行命令:C:\Users\user\AppData\Local\Android\ android-studio android - 4.4 w \ sdk \构建工具\ \ aapt。exe包- f——no-crunch我C:\Users\user\AppData\Local\Android\ android-studio \ sdk \ \ android-20 \ android平台。jar - m C:\Users\user\ AndroidStudioProjects \ DartsApp \ app \制造\中间体\ \调试\ AndroidManifest体现。xml - s C:\Users\user\ AndroidStudioProjects \ DartsApp \ app \制造\中间体\ res \调试——C:\Users\user\ AndroidStudioProjects \ DartsApp \ app \制造\中间体\资产\调试- m - j C:\Users\user\ AndroidStudioProjects \ DartsApp \ app \制造\ \ r \ \来源生成调试- f C:\Users\user\ AndroidStudioProjects \ DartsApp \ app \制造\中间体\ libs \ app-debug。ap_——调试模式定制包com.dartstransit。dartsapp -0 apk——输出-文本符号c:) usersusers\ AndroidStudioProjects\ dartsapp \app\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

Error Code:

错误代码:

1

Output:

输出:

res\drawable-hdpi-v4\bus_w.png:0: error: Resource entry bus_w is already defined.
res\drawable-hdpi-v4\bus_w.jpg:0: Originally defined here.

As you can see there are two files of name bus_w with different extensions on the same folder. I had already removed those files from the project and still getting the error, so I decided to check every single folder of the project that was reference in the compiler line in the error message. Finally found that there was a copy of the file bus_w.png in the folder app\build\intermediates\res\debug\drawable-mdpi-v4.

正如您所看到的,在同一个文件夹中有两个具有不同扩展名的名称bus_w文件。我已经从项目中删除了这些文件,并且仍然得到了错误,所以我决定检查在错误消息中在编译器中引用的项目的每一个文件夹。最后发现文件bus_w的副本。png在文件夹应用\构建\中间\ \调试\调试-mdpi-v4。

I just deleted it and voila, problem solved.

我把它删掉了,问题解决了。

#4


3  

A simple Build > Rebuild project helped me

一个简单的>重建项目帮助了我。

#5


1  

Did you try rename this file to other name? It seem one of your libraries have same resource.

您是否尝试将此文件重命名为其他名称?您的库中似乎有相同的资源。

I see that many devs(include me) had issue with ic_launcher too. I think you want to try mipmap instead drawable. So we will have something like this:

我看到许多devs(包括我)也有使用ic_launcher的问题。我认为你想试试mipmap,而不是drawable。所以我们会有这样的东西:

\res\mipmap-hdpi
\res\mipmap-mdpi
\res\mipmap-xhdpi
\res\mipmap-xxhdpi

Hope this help.

希望这个有帮助。

#6


0  

I have also encountered this error recently.Here is my solution that works,hope it will help you.

我最近也遇到过这个错误。这是我的解决方案,希望它能帮到你。

1.only keep 9 patch version image in the drawable-hdpi folder

1。在drawable-hdpi文件夹中只保留9个补丁版本的图像。

2.make sure the code related to this problem in xml file remains the same: android:background="@drawable/msg_left"

2。确保在xml文件中与此问题相关的代码保持不变:android:background="@drawable/msg_left"

instead of using the code:

而不是使用代码:

android:background="@drawable/msg_left.9"

android:背景= " @drawable / msg_left.9”

PS:My original image name is msg_left,and my 9 patch version image name is msg_left.9

PS:我的原始图像名称是msg_left,我的9个补丁版本的图像名称是msg_left.9。

#7


0  

I did the trick by moving the icon

我通过移动图标来完成这个任务。

drawable/ic_launcher

to

mipmap/ic_launcher

and it worked fine :)

而且效果很好:)


推荐阅读
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 【Windows】实现微信双开或多开的方法及步骤详解
    本文介绍了在Windows系统下实现微信双开或多开的方法,通过安装微信电脑版、复制微信程序启动路径、修改文本文件为bat文件等步骤,实现同时登录两个或多个微信的效果。相比于使用虚拟机的方法,本方法更简单易行,适用于任何电脑,并且不会消耗过多系统资源。详细步骤和原理解释请参考本文内容。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • JavaSE笔试题-接口、抽象类、多态等问题解答
    本文解答了JavaSE笔试题中关于接口、抽象类、多态等问题。包括Math类的取整数方法、接口是否可继承、抽象类是否可实现接口、抽象类是否可继承具体类、抽象类中是否可以有静态main方法等问题。同时介绍了面向对象的特征,以及Java中实现多态的机制。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • Spring学习(4):Spring管理对象之间的关联关系
    本文是关于Spring学习的第四篇文章,讲述了Spring框架中管理对象之间的关联关系。文章介绍了MessageService类和MessagePrinter类的实现,并解释了它们之间的关联关系。通过学习本文,读者可以了解Spring框架中对象之间的关联关系的概念和实现方式。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
author-avatar
一坛苦水_179
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有