Lollipop AppCompat-v7 21 - Theme attribute is already defined

I wanted to update my project to support Android Lollipop and API 21, so I changed the version of AppCompat to 21.0.0 and my target SDK to 21.

But now, when I try to synchronize the project with gradle files, it gives me 102 errors , which was not before:

1 error "Attribute 'theme' has already defined" - set by my colors.XML file,

and another 101 error "no resources found that matches the given name..." - most of them are material - are set by "build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.XML" .

Already updated all the SDK tools in the Android SDK software, Using the beta version of Android Studio 0.8.9.

Can anyone help? Thank.

+68
android android-5.0-lollipop
Oct 17 '14 at 19:29
source share
6 answers

I had the first problem. This can be fixed by updating the Google Play Services dependency to 6.1. +.

In Gradle (which I hope you are using): compile 'com.google.android.gms: play-services: 6.1. + '

Regarding the second problem - as stated in the comments, you should make sure ALL the components of your SDK installation are updated.

+122
Oct 17 '14 at 19:59
source share

I had the same problem, but updating to the latest versions did not help.

But the error message Attribute "theme" has already been defined has changed to Attribute "layout" has already been defined

In google play services settings i found this

  <declare-styleable name="WalletFragmentOptions"> <!-- Theme to be used for the Wallet selector --> - <attr name="theme" format="enum"> + <attr name="appTheme" format="enum"> 

And that is the key.

If you have the attributes attr.xml theme or layout, or possibly something else, rename it. Merge doesn't seem to be able to handle this.

+17
Oct 27 '14 at 12:25
source share

Gradle in Android Studio offers the latest version of com.google.android.gms:play-services . After updating this version to the latest version, the problem was resolved.

compile 'com.google.android.gms:play-services:8.3.0'

+2
Dec 10 '15 at 17:11
source share

Sometimes the library you use has this attribute. I used the "Sliding Panel" panel , and during the build I received the following error. I had the following items in my dependency libraries:

 dependencies { compile 'com.android.support:appcompat-v7:20.0.0' compile 'com.sothree.slidinguppanel:library:+' // ... } 

I fixed my problem by deleting the sliding library :(

0
Dec 03 '14 at 9:02
source share

After adding a new action to my project, it looks like Android Studio automatically updated my dependencies after this error began to appear.

I changed the following dependencies to the latest compatibility libraries:

 compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3' 

the ones I had in my gradle.build before Studio edited it without asking me:

 compile 'com.android.support:support-v4:20.0.0' compile 'com.android.support:appcompat-v7:20.0.0' 

Then let Studio do the synchronization and your build should work.

0
Feb 19 '15 at 14:22
source share

For Eclipse users:

  • go with the accepted answer from tilal6991
  • but keep in mind that after that you must reimport the google play service project

Because if you followed the recommendations for installing gps, you only have a copy of it in the workspace, which will not be updated.

0
Dec 22 '15 at 13:46
source share



All Articles