Akrides
Akrides

Reputation: 11

Android Studio build fails because it cannot merge Renderscript files

I have begun migrating one of our Android project from Eclipse (Using ADT) to a new build system, Gradle. Since the new Android Studio is using Gradle, I modified the project so it could be correctly imported into Android Studio.

All the steps I did were outside Android Studio (adding Gradle, creating the wrapper, changing the source files directories, etc...), and both inside and outside Studio the result are the same (using the "gradlew build" command, or variations thereof such as "gradlew aR").

The following is the error message:

C:\Users\prog\Documents\git\PROJECT>gradlew aR
:preBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:prepareReleaseDependencies
:compileReleaseAidl
:compileReleaseRenderscript
:generateReleaseBuildConfig
:mergeReleaseAssets
:mergeReleaseResources
C:\Users\prog\Documents\git\PROJECT\build\res\rs\release\raw\levelsfilter
rs.bc: Error: Duplicate resources: C:\Users\prog\Documents\git\PROJECT\bu
ild\res\rs\release\raw\levelsfilterrs.bc:raw/levelsfilterrs, C:\Users\prog\Docum
ents\git\PROJECT\src\main\res\raw\levelsfilterrs.bc:raw/levelsfilterrs
:mergeReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeReleaseResources'.
C:\Users\prog\Documents\git\PROJECT\build\res\rs\release\raw\levelsfilt
errs.bc: Error: Duplicate resources: C:\Users\prog\Documents\git\PROJECT\
build\res\rs\release\raw\levelsfilterrs.bc:raw/levelsfilterrs, C:\Users\prog\Doc
uments\git\PROJECT\src\main\res\raw\levelsfilterrs.bc:raw/levelsfilterrs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.277 secs

Here is the Gradle build file.

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android'

android {
    compileSdkVersion 11
    buildToolsVersion "19"
}

The RS files follow the directory convention, such as "src/main/rs". Before, they were alongside the *.java files that were using them.

Upvotes: 1

Views: 2840

Answers (1)

Jason YiZhang Chen
Jason YiZhang Chen

Reputation: 321

Just delete bc file in your resource folder.

Your case:

remove=> C:\Users\prog\Documents\git\PROJECT\src\main\res\raw\levelsfilterrs.bc

Reason:

After compile renderscript, llvm will generate *.bc file in order to bundled with final apk. Because you already have *.bc file, it caused merge resources task failed.

Upvotes: 3

Related Questions