I'm updating my app to bring material theme support(my app uses Google Play Services)
When I sync my project, this showed up:
...\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.1.11\res\values\wallet_colors.xml
Error:Attribute "showText" has already been defined
My gradle dependencies:
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:6.1.11'
// the latest version of play-services is 6.1.11
If I exclude appcompat-v7 then the project compiles without errors.
Did I got too excited about lollipop and didn't read the docs properly? How can I fix this?
Part of the build script:
compileSdkVersion 21
buildToolsVersion '21.0.1'
dexOptions {
preDexLibraries true
//incremental true
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 11
versionName '1.0'
renderscriptTargetApi 21
renderscriptSupportMode true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Local Google repository looks like this:
@igavran answer points to the right direction but I wanted to give more comprehensive answer, so there it is:
Gradle Resource Merger merges all resource folders from all dependencies and place into single folder. In case there are duplicates build process will fail.
For some weird reason, Android Studio points to the wallet_colors.xml of the Google Play Service library in the Messages window. Google Play Service has nothing to do with this problem. Fortunately, if you look below under Output: label, you will find the right path to the problem e.g.
You can also build your project from command line and get the right path.
Inside values.xml file in line 172(in your case different line) you would find a <declare-styleable>
with property named "color"("showText" in your case). 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. I guess it will be located inside /values/attrs.xml file.
I spent last two hours on the same issue and in my case the problem was that I had defined my own attribute "showText" (in res/values/attrs.xml) which was in collision with attribute defined in <declare-styleable name="SwitchCompat">
.
This problem does not exist when using appcompat-v7:20 but with appcompat-v7:21 build fails.
Don't use the whole play services like this following example 1
example 1: compile 'com.google.android.gms:play-services:7.5.0'
Use those services that you want to use in you application. For example if you want to use Google+ service than use as following example 2
example 2: compile 'com.google.android.gms:play-services-plus:7.5.0'
for more services visit: Setting Up Google Play Services
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With