Android Error:Attribute "theme" has already been defined
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26546510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error:Attribute "theme" has already been defined
提问by ash
I am using Android studio for building application. I am using this following dependencies:
I am using Android studio for building application. I am using this following dependencies:
- play services :
compile 'com.google.android.gms:play-services:5.2.08'
- app combat v7 :
compile 'com.android.support:appcompat-v7:21.0.0'
- support Cardview :
compile 'com.android.support:cardview-v7:21.0.0'
- support Recycler view :
compile 'com.android.support:recyclerview-v7:21.0.0'
- play services :
compile 'com.google.android.gms:play-services:5.2.08'
- app combat v7 :
compile 'com.android.support:appcompat-v7:21.0.0'
- support Cardview :
compile 'com.android.support:cardview-v7:21.0.0'
- support Recycler view :
compile 'com.android.support:recyclerview-v7:21.0.0'
I am getting following error while building my app:
I am getting following error while building my app:
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
Code Styles.xml
Code Styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
Code wallet_attrs.xml
Code wallet_attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 Google Inc. All Rights Reserved. -->
<resources>
<!-- Attributes for the WalletFragment <fragment> 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>
回答by cV2
just use latest (21)
appCompat and
google play services library
just use latest (21)
appCompat and
google play services library
For example:
For example:
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'
then everything works :)
then everything works :)
回答by arunprakashpj
Just check, whether you have a file named attrs.xml. In that file replace the following line
Just check, whether you have a file named attrs.xml. In that file replace the following line
<attr name="theme" format="reference" />
with
with
<attr name="apptheme" format="reference" />
That is, rename the theme name. Now clean the project. This solved my issue.
That is, rename the theme name. Now clean the project. This solved my issue.
回答by brandall
I had the same issue developing in Eclipse after updating content via the SDK manager.
I had the same issue developing in Eclipse after updating content via the SDK manager.
I had to completely remove the Google Play Services library from the Workspace and then copy and import the updated version following the instructions here.
I had to completely remove the Google Play Services library from the Workspace and then copy and import the updated version following the instructions here.
No updating of the referenced jars helped me - Only a full fresh import. This included updating the android-support-v7-appcompat import.
No updating of the referenced jars helped me - Only a full fresh import. This included updating the android-support-v7-appcompat import.
回答by Emmanuel Harguindey
If you want to keep supporting older android versions (2.3.x, 3.x.x, 4.0) use a modified version of your library removing wallet classes and resources (given that you don't need wallet functionality.) That avoids this "theme" attr problem. I am using play-services-5.0.89.arr
with no problem.
If you want to keep supporting older android versions (2.3.x, 3.x.x, 4.0) use a modified version of your library removing wallet classes and resources (given that you don't need wallet functionality.) That avoids this "theme" attr problem. I am using play-services-5.0.89.arr
with no problem.
In particular, remove com.google.android.gms.wallet.*
classes and wallet_*.xml
resources and you are done.
In particular, remove com.google.android.gms.wallet.*
classes and wallet_*.xml
resources and you are done.
回答by ash
Thanks Hirak as you mentioned the error was with dependency. solved it using following versions of library:
Thanks Hirak as you mentioned the error was with dependency. solved it using following versions of library:
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:4.+'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'