简体   繁体   中英

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 :

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 !

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM