I am trying to update my appcompat-v7 in Android Studio project from v20.0.0 to 21.0.0 for use material design component but I allways get the same error:
"Error:Attribute "color" has already been defined"
I have not idea about what to do for fix this error, I searched in internet but I cant get the answer. Here is my gradle:
android {
compileOptions.encoding = "iso-8859-1"
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.test"
minSdkVersion 11
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.2.4'
compile "com.android.support:appcompat-v7:21.0.+"
}
Here is the path where the conflict exist
C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\values\values.xml
and this is other error:
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Abel Dominguez\AppData\Local\Android\sdk1\build-tools\build-tools-21.1.1\aapt.exe package -f --no-crunch -I C:\Users\Abel Dominguez\AppData\Local\Android\sdk1\platforms\android-21\android.jar -M C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\debug -A C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\assets\debug -m -J C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\generated\source\r\debug -F C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package com.wherefriend -0 apk --output-text-symbols C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\symbols\debug
Error Code:
1
Output:
C:\Users\Abel Dominguez\Documents\PROYECTOS_ANDROID\definitivos\d2\app\build\intermediates\res\debug\values\values.xml:94: error: Attribute "color" has already been defined
My problem was solved after I read the answer by @petey. If you look at the line displayed in error message you can precisely determine which attribute is causing problem.
In my case, it was an attribute named color
in a custom attrs
xml file. That custom view wasn't used so I just commented that line and problem was solved.
Possible solution steps
Check error output to find the path to the file and line number that is causing problems
Go to that file through your file system explorer and look for the line in question
That line should mention what (custom) view has an attribute that is already defined somewhere.
Back in the project in you IDE, find that attribute and if it is not used comment, otherwise if it IS used, change it's name.
You should remove this line
compile 'com.android.support:support-v4:20.0.0'
and use the same dependency used by appcompat:
compile 'com.android.support:support-v4:21.0.+'
Also I suggest to fix the 21.0.3 instead of 21.0.+
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