简体   繁体   English

错误:在Android中使用两个库项目时,已经定义了属性“***”

[英]error: Attribute “***” has already been defined when using two library projects in Android

I'm using android-support-v7-appcompat as a library in my Android project. 我在我的Android项目中使用android-support-v7-appcompat作为库。 Now I want to include actionbarsherlock as another library project. 现在我想将actionbarsherlock包含为另一个库项目。 When I add the second library, it gives so many errors like below 当我添加第二个库时,它会产生如下许多错误

android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined

By changing one attribute value and it's related code snippet is a one solution that I've tried. 通过更改一个属性值,它的相关代码片段是我尝试过的一个解决方案。 But when there are nearly 80 lines like above, it will get a messy. 但是当上面有近80条线路时,它会变得凌乱。 Is there any other way I can solve this issue? 还有其他方法可以解决这个问题吗?

The correct way to solve this problem is by updating Android Support Libraries in all relevant projects and library projects. 解决此问题的正确方法是更新所有相关项目和库项目中的Android支持库。 In my case I've used Android support library and also one of the library project to implement my application. 在我的例子中,我使用了Android支持库,也使用了一个库项目来实现我的应用程序。 When I update both libraries, the problem solved. 当我更新两个库时,问题就解决了。 The way of updating Android support library is; 更新Android支持库的方法是;

  • Right click on the project 右键单击该项目
  • Select Android Tools from the pop up window 从弹出窗口中选择Android Tools
  • Select Add Support Library 选择添加支持库

Properties => Android中删除appcompact支持库项目

Gradle Resource Merger merges all resource folders from all dependencies and place into single folder. Gradle Resource Merger合并来自所有依赖项的所有资源文件夹并放入单个文件夹中。 In case there are duplicates build process will fail. 如果存在重复,则构建过程将失败。

Fortunately, if you look below under Output: label, you will find the right path to the problem. 幸运的是,如果你看下面的输出:标签,你会找到问题的正确途径。

Here is an example 这是一个例子

在此输入图像描述

in your case it is android-support-v7-appcompat\\res\\values\\attrs.xml:476: error: Attribute "attributeName" has already been defined 在你的情况下,它是android-support-v7-appcompat\\res\\values\\attrs.xml:476: error: Attribute "attributeName" has already been defined

You can also build your project from command line and get the right path. 您还可以从命令行构建项目并获得正确的路径。 attributeName Inside values\\attrs.xml file on line 476 you would find a with property named "attributeName". attributeName在第476行的values\\attrs.xml文件中,您会找到名为“attributeName”的属性。 Most probably it is your own styleable that you have to change to get rid of the duplicate. 最有可能是你自己的风格,你必须改变,以摆脱重复。

So now, when you know the reason, you can locate that property in your project module and replace it with different name. 所以现在,当你知道原因时,你可以在项目模块中找到该属性并用不同的名称替换它。

我通过从项目中删除appcompact并将样式更改为来解决了这个问题

<style name="AppBaseTheme" parent="Theme.Sherlock">

我更新了构建工具版本并重新生成,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用支持库我得到一个错误,已经在android中定义了属性“” - while using support library i am getting an error that Attribute “ ” has already been defined in android Android:错误:(464)属性“ dividerPadding”已经定义 - Android: Error:(464) Attribute “dividerPadding” has already been defined Gradle错误:Android Studio中“属性“ rippleColor”已定义” - Gradle error: “Attribute ”rippleColor“ has already been defined” in android studio 错误:(1)属性“ rippleColor”已在android studio中定义 - Error:(1) Attribute “rippleColor” has already been defined in android studio Gradle错误“属性”xxx“已在Android Studio中定义” - Gradle error “Attribute ”xxx“ has already been defined” in Android Studio 错误:属性“ android:orientation”已经定义 - Error:Attribute “android:orientation” has already been defined Android属性已经定义 - Android Attribute has already been defined Android:属性&#39;rippleColor&#39;已经定义 - Android: Attribute 'rippleColor' has already been defined 错误:(2)属性“ spinnerStyle”已被定义 - Error:(2) Attribute “spinnerStyle” has already been defined 错误:(2)属性“ barLength”已经定义 - Error:(2) Attribute “barLength” has already been defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM