How To Get A Notification When Android Studio Finish A Build?
Solution 1:
you need to add plugins announce and build announcements. the following destinations are supported: Twitter, notify-send (Ubuntu), Snarl (Windows), Growl (macOS). those are the plugins required:
rootProject {
apply plugin: "announce"
apply plugin: 'build-announcements'
}
and to finalize the build process (see supported notification services):
// it finalizes :assemble
task finalizeBuild {
doLast {
println(":finalizeBuild > doLast")
announce.announce("task :assemble completed!", "snarl")
}
}
tasks.whenTaskAdded { task ->
if (task.name == "assembleDebug") {
task.finalizedBy finalizeBuild
} elseif (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}
Solution 2:
The easiest way to achieve what you need :
In Android Studio, go into Preferences > Appearance & Behavior > Notifications
, go down to Gradle Build (Logging) and check the Read aloud box.
This will speak Gradle build finished in x minutes and x seconds when your build is complete.
Solution 3:
Have you considered using sound for notification?
You can add this to your app/.gradle
file inside android{ }
tag :
afterEvaluate {
gradle.buildFinished{ BuildResult buildResult ->
if (buildResult.failure) {
['powershell', """(New-Object Media.SoundPlayer "C:\\failed_notif.wav").PlaySync();"""].execute()
println("failed doing task")
} else {
['powershell', """(New-Object Media.SoundPlayer "C:\\succeed_notif.wav").PlaySync();"""].execute()
println("build finished")
}
}
}
If you want the notification only run after specific buildType finish (success build only), you can use :
afterEvaluate {
assembleDebug.doLast{ //play sound for debug buildType }
assembleRelease.doLast{ //play sound for release buildType }
}
Please note that this method can only run with .wav
file. If you want to use an .mp3
you can try this.
Post a Comment for "How To Get A Notification When Android Studio Finish A Build?"