首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:属性“主题”已被定义

错误:属性“主题”已被定义
EN

Stack Overflow用户
提问于 2014-10-24 10:52:27
回答 5查看 24.7K关注 0票数 22

我正在使用Android工作室来构建应用程序。我使用以下依赖项:

  1. 播放服务:compile 'com.google.android.gms:play-services:5.2.08'
  2. 应用战斗v7:compile 'com.android.support:appcompat-v7:21.0.0'
  3. 支持Cardview:compile 'com.android.support:cardview-v7:21.0.0'
  4. 支持回收器视图:compile 'com.android.support:recyclerview-v7:21.0.0'

在构建我的应用程序时,我会收到以下错误:

代码语言:javascript
复制
app/build/intermediates/exploded-aar/com.google.android.gms/play-services/5.2.08/res/values/wallet_attrs.xml
    Error:Attribute "theme" has already been defined

代码Styles.xml

代码语言:javascript
复制
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

代码wallet_attrs.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 Google Inc. All Rights Reserved. -->
<resources>
    <!-- Attributes for the WalletFragment &lt;fragment&gt; tag -->
    <declare-styleable name="WalletFragmentOptions">
        <!-- Theme to be used for the Wallet selector -->
        <attr name="theme" format="enum">
            <enum name="holo_dark" value="0"/>
            <enum name="holo_light" value="1"/>
        </attr>
        <!-- Google Wallet environment to use -->
        <attr name="environment" format="enum">
            <enum name="production" value="1"/>
            <enum name="sandbox" value="0"/>
            <enum name="strict_sandbox" value="2"/>
        </attr>
        <!-- A style resource specifing attributes to customize the look and feel of WalletFragment -->
        <attr name="fragmentStyle" format="reference"/>
        <!-- Fragment mode -->
        <attr name="fragmentMode" format="enum">
            <enum name="buyButton" value="1"/>
            <enum name="selectionDetails" value="2"/>
        </attr>
    </declare-styleable>

    <!-- Attributes that may be specified in a style resource to customize the look and feel of
         WalletFragment -->
    <declare-styleable name="WalletFragmentStyle">
        <!-- Height of the buy button. This includes an 8dp padding (4dp on each side) used for
             pressed and focused states of the button. The value can be a specific height, e.g.
             "48dp", or special values "match_parent" and "wrap_content". -->
        <attr name="buyButtonHeight" format="dimension">
            <enum name="match_parent" value="-1" />
            <enum name="wrap_content" value="-2" />
        </attr>
        <!-- Width of the buy button. This includes an 8dp padding (4dp on each side) used for
             pressed and focused states of the button. The value can be a specific width, e.g.
             "300dp", or special values "match_parent" and "wrap_content". -->
        <attr name="buyButtonWidth" format="dimension">
            <enum name="match_parent" value="-1" />
            <enum name="wrap_content" value="-2" />
        </attr>
        <!-- Text on the buy button. Must be one of "buy_with_google", "buy_now" and "book_now" -->
        <attr name="buyButtonText" format="enum">
            <enum name="buy_with_google" value="1"/>
            <enum name="buy_now" value="2"/>
            <enum name="book_now" value="3"/>
        </attr>
        <!-- Appearance of the buy button. Must be one of "classic", "grayscale" and "monochrome" -->
        <attr name="buyButtonAppearance" format="enum">
            <enum name="classic" value="1"/>
            <enum name="grayscale" value="2"/>
            <enum name="monochrome" value="3"/>
        </attr>
        <!-- TextAppearance for masked wallet details -->
        <attr name="maskedWalletDetailsTextAppearance" format="reference"/>
        <!-- TextAppearance for headers describing masked wallet details -->
        <attr name="maskedWalletDetailsHeaderTextAppearance" format="reference"/>
        <!-- Masked wallet details background -->
        <attr name="maskedWalletDetailsBackground" format="reference|color"/>
        <!-- TextAppearance for the "Change" button in masked wallet details view -->
        <attr name="maskedWalletDetailsButtonTextAppearance" format="reference"/>
        <!-- "Change" button background in masked wallet details view -->
        <attr name="maskedWalletDetailsButtonBackground" format="reference|color"/>
        <!-- Color of the Google Wallet logo text in masked wallet details view -->
        <attr name="maskedWalletDetailsLogoTextColor" format="color"/>
        <!-- Type of the wallet logo image in masked wallet details view -->
        <attr name="maskedWalletDetailsLogoImageType" format="enum">
            <enum name="classic" value="1"/>
            <enum name="monochrome" value="2"/>
        </attr>
    </declare-styleable>
</resources>
EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2014-10-27 13:42:12

只需使用最新(21)

appCompat和

google播放服务库

例如:

代码语言:javascript
复制
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0' 
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.google.android.gms:play-services:6.1.11'

那么所有的事情都会发生:)

票数 41
EN

Stack Overflow用户

发布于 2015-03-09 20:03:32

只要检查一下,您是否有一个名为attrs.xml的文件。在该文件中替换以下行

代码语言:javascript
复制
 <attr name="theme" format="reference" />

使用

代码语言:javascript
复制
 <attr name="apptheme" format="reference" />

也就是说,重命名主题名。现在清理一下这个项目。这解决了我的问题。

票数 11
EN

Stack Overflow用户

发布于 2014-10-25 13:46:45

在通过SDK管理器更新内容之后,我在Eclipse中也遇到了同样的问题。

我必须从工作区中完全删除Google服务库,然后复制并导入更新后的版本按照这里的说明

没有更新引用的jars帮助我-只有一个完整的新的导入。这包括更新android-support-v7-appcompat导入。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26546510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档