我刚刚从Android Studio 0.6升级到0.8.3(在Linux Mint 15上),现在我的版本没有按预期工作。在我的gradle文件中,我有许多自定义任务可以执行预建步骤(复制文件,调整图像大小等)。
// 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步骤,则不会运行:
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块不再运行一样。奇怪的是,如果我在终端中运行它可以工作:
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
有人可以帮忙吗?感谢
答案 0 :(得分:1)
我修改了它:
gradle.projectsEvaluated {
copyRes.dependsOn resizeImageIcon
convertToOGG.dependsOn copyRes
preBuild.dependsOn copyRes, convertToOGG
}
到
copyRes.dependsOn resizeImageIcon
convertToOGG.dependsOn copyRes
preBuild.dependsOn copyRes, convertToOGG