Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile with Android Studio 1.3, gradle says a resource was already defined

Since I updated to Android Studio 1.3, I'm running into a very weird issue. When I try to launch my apps, it says me that :

"Gradle 2.4 requires Android Gradle plugin 1.2.0 (or newer) but project is using version 1.0.0. Please use Android Gradle plugin 1.2.0 or newer."

When I click on "Fix plugin version and sync project", it changes this in my build.gradle files

dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
}

to this :

dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
}

But I cannot launch my app, because of this resource (in my sw600dp/config.xml file) :

<item name="is_tablet" type="bool">true</item>

It says that this resource is already defined, in the auto-generated file "values-sw600dp-v13/values.xml" :

<resources>
    <!-- From: file:.../src/main/res/values-sw600dp/config.xml -->
    <eat-comment/>
    <item name="is_tablet" type="bool">true</item>
</resources>

(It says, when I open this file, that "Files under the build folder are generated and should not be edited").

If I comment, in the sw600dp/config.xml file, the resource, it works, but it worked before, it should not say that it has already been defined ! And it does that in all of my apps !

I already tried to :

  • Delete the line in the auto-generated file; of course, it creates the line automatically and it still can't compile.
  • Input "./gradlew clean build assemble" in the console. What it did was to download "https://services.gradle.org/distributions/gradle-2.2.1-all.zip", and it ended with :

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugResources'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/Library/Android/sdk/build-tools/21.1.2/aapt'' finished with non-zero exit value 1

  • I also tried to do "File > Invalidate Caches/Restart"

None of this worked !

What can I do ?

(I'm using a MAC)

Thanks a lot in advance !

like image 502
IKIKN Avatar asked Dec 10 '25 10:12

IKIKN


1 Answers

This is caused because of changes to how AAPT crunches resources, now it fails if there are identically named resources in any library that you may have included in the project (only .aar dependencies can contain resources).

The solution is to find where the conflict is coming from and exclude it from the project.

like image 193
Major Laslo Avatar answered Dec 13 '25 00:12

Major Laslo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!