Android Studio 0.8 - 不再运行自定义任务 [英] Android Studio 0.8 - No longer runs custom tasks
问题描述
我刚刚从 Android Studio 0.6 升级到 0.8.3(在 Linux Mint 15 上),现在我的构建没有按预期工作.在我的 gradle 文件中,我有很多自定义任务,它们执行预构建步骤(复制文件、调整图像大小等).
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
}
默认情况下,这些不再在 IDE 中运行.它们是 preBuild 步骤的依赖项,但如果我在 IDE 中手动运行 preBuild 步骤,则不会运行:
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
就像 gradle.projectsEvaluated 块不再运行一样.奇怪的是,如果我在终端中运行它,它可以工作:
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
有人可以帮忙吗?谢谢
推荐答案
我通过更改修复了它:
gradle.projectsEvaluated {
copyRes.dependsOn resizeImageIcon
convertToOGG.dependsOn copyRes
preBuild.dependsOn copyRes, convertToOGG
}
到
copyRes.dependsOn resizeImageIcon
convertToOGG.dependsOn copyRes
preBuild.dependsOn copyRes, convertToOGG
这篇关于Android Studio 0.8 - 不再运行自定义任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!