Question

I have just upgraded from Android Studio 0.6 to 0.8.3 (on Linux Mint 15) and now my build is not working as expected. In my gradle file I have lots of custom Tasks which do prebuild steps (copying files, resizing images, etc).

// lots of tasks snipped  
task convertToOGG(type:Exec) {
    ext.srcDir = 'bb/src/main/buildAssets/wavs/'
    ext.destDir = 'bb/src/main/res/raw/'
    workingDir '..'
    commandLine 'python', 'scripts/convertToOGG.py', srcDir, destDir
}

gradle.projectsEvaluated {
    copyRes.dependsOn resizeImageIcon
    convertToOGG.dependsOn copyRes

    preBuild.dependsOn copyRes, convertToOGG
}

These don't run by default in the IDE any more. They are dependencies of the preBuild step, but don't run if I manually run the preBuild step in the IDE:

Executing tasks: [preBuild]

Configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:Bb:preBuild
:libraries:bbengine:preBuild
:libraries:facebook:preBuild

BUILD SUCCESSFUL

Total time: 2.296 secs

Its like the gradle.projectsEvaluated block is no longer run. Strangely if I run it in a terminal it works:

pickles@sirius /workspace/bb/code/trunk/bb $ ./gradlew preBuild
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:Bb:resizeImageIcon
/workspace/babybot/code/trunk/BbProject
RESIZE IMAGE:  Bb/src/main/buildAssets/oversize/image_icon.png
(1024, 1024) RGBA
Targets:  5
Bb/src/main/buildAssets/res/drawable-xxhdpi/ic_launcher.png (144, 144)
Saved a (144, 144) version to Bb/src/main/buildAssets/res/drawable-xxhdpi/ic_launcher.png
Bb/src/main/buildAssets/res/drawable-xhdpi/ic_launcher.png (96, 96)
Saved a (96, 96) version to Bb/src/main/buildAssets/res/drawable-xhdpi/ic_launcher.png
Bb/src/main/buildAssets/res/drawable-hdpi/ic_launcher.png (72, 72)
Saved a (72, 72) version to Bb/src/main/buildAssets/res/drawable-hdpi/ic_launcher.png
Bb/src/main/buildAssets/res/drawable-mdpi/ic_launcher.png (48, 48)
Saved a (48, 48) version to Bb/src/main/buildAssets/res/drawable-mdpi/ic_launcher.png
Bb/src/main/buildAssets/res/drawable-ldpi/ic_launcher.png (36, 36)
Saved a (36, 36) version to Bb/src/main/buildAssets/res/drawable-ldpi/ic_launcher.png
:Bb:copyRes UP-TO-DATE
:Bb:convertToOGG
Skipping chunk of type "LIST", length 106
Opening with wav module: WAV file reader
Encoding "audio_robot_jump.wav" to 
         "audio_robot_jump.ogg" 
at quality 3.00
    [ 79.6%] [ 0m00s remaining] / 

Done encoding file "audio_robot_jump.ogg"

    File length:  0m 02.0s
    Elapsed time: 0m 00.1s
    Rate:         39.5641
    Average bitrate: 48.3 kb/s

:Bb:preBuild
:libraries:bbengine:preBuild
:libraries:facebook:preBuild

BUILD SUCCESSFUL

Total time: 15.619 secs

Can anyone help? Thanks

Was it helpful?

Solution

I fixed it by changing:

gradle.projectsEvaluated {
    copyRes.dependsOn resizeImageIcon
    convertToOGG.dependsOn copyRes

    preBuild.dependsOn copyRes, convertToOGG
}

to

copyRes.dependsOn resizeImageIcon
convertToOGG.dependsOn copyRes

preBuild.dependsOn copyRes, convertToOGG
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top