Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lollipop AppCompat-v7 21 - Attribute "theme" has already been defined

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

But now, When I'm trying to sync project with gradle files, it gives me 102 errors that weren't there before:

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

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

Already updated all SDK tools in Android SDK software, Using Android Studio 0.8.9 Beta.

Can anyone help? Thanks.

like image 602
user3184899 Avatar asked Oct 17 '14 19:10

user3184899


3 Answers

I had the first issue as well. It can be fixed by updating the Google Play Services dependency to 6.1.+.

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

As for the second issue - as people have said in the comments, you should make sure ALL the components in your SDK installation are up to date.

like image 137
tilal6991 Avatar answered Nov 19 '22 09:11

tilal6991


I had the same problem but upgrade to latest versions doesn't helped.

But error message Attribute “theme” has already been defined changed to Attribute “layout” has already been defined

In Google Play Services changes I've 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 this is the key.

If you have in your attr.xml attributes theme or layout or maybe something else - rename it. It seems merger can't deal with it.

like image 17
Fedor Kazakov Avatar answered Nov 19 '22 09:11

Fedor Kazakov


Gradle in the Android studio suggests the latest version of com.google.android.gms:play-services. After updating that to the latest version, the problem got solved.

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

like image 2
Vikas Avatar answered Nov 19 '22 09:11

Vikas