How to get a notification when Android Studio finish a build?











up vote
-1
down vote

favorite












I would like to get a notification when Gadle finish to build my app,



Please note that I'm not very familliar with Gradle except for the usual statements used in Android Studio but I'm glad I could learn something.



The best way I've seen so far seems to use announce and build-announcements plugins, as it is stated in this link. Unfortunately it is meant for Gradle in general and I cannot see how to adapt it to Android Studio's builds system. BTW, I'm on windows and have Snarl installed but no clue about how to make it work with Android Studio.



As in the tutorial, I applied both plugins to my app/build.gradle.



I first tried to adapt the code from this SO question. Since there was no real infromation about it, I wrote these lines at the root of the gradle file.



assembleRelease.doLast {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}


However, Gradle won't even sync, throwing this error:




Could not get unknown property 'assembleRelease' for project ':myApplication' of type org.gradle.api.Project.




I then tried to create a task like seen in this other SO question:



task notification() {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}
build.finalizedBy(notification) //


This doesn't throw any error but no notification is showing.



Why did my attempts failed ? How could I achieve my goal ?



If possible, information about how I should have searched to find this information myself is very welcome.










share|improve this question
























  • Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
    – Dan Chaltiel
    yesterday















up vote
-1
down vote

favorite












I would like to get a notification when Gadle finish to build my app,



Please note that I'm not very familliar with Gradle except for the usual statements used in Android Studio but I'm glad I could learn something.



The best way I've seen so far seems to use announce and build-announcements plugins, as it is stated in this link. Unfortunately it is meant for Gradle in general and I cannot see how to adapt it to Android Studio's builds system. BTW, I'm on windows and have Snarl installed but no clue about how to make it work with Android Studio.



As in the tutorial, I applied both plugins to my app/build.gradle.



I first tried to adapt the code from this SO question. Since there was no real infromation about it, I wrote these lines at the root of the gradle file.



assembleRelease.doLast {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}


However, Gradle won't even sync, throwing this error:




Could not get unknown property 'assembleRelease' for project ':myApplication' of type org.gradle.api.Project.




I then tried to create a task like seen in this other SO question:



task notification() {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}
build.finalizedBy(notification) //


This doesn't throw any error but no notification is showing.



Why did my attempts failed ? How could I achieve my goal ?



If possible, information about how I should have searched to find this information myself is very welcome.










share|improve this question
























  • Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
    – Dan Chaltiel
    yesterday













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I would like to get a notification when Gadle finish to build my app,



Please note that I'm not very familliar with Gradle except for the usual statements used in Android Studio but I'm glad I could learn something.



The best way I've seen so far seems to use announce and build-announcements plugins, as it is stated in this link. Unfortunately it is meant for Gradle in general and I cannot see how to adapt it to Android Studio's builds system. BTW, I'm on windows and have Snarl installed but no clue about how to make it work with Android Studio.



As in the tutorial, I applied both plugins to my app/build.gradle.



I first tried to adapt the code from this SO question. Since there was no real infromation about it, I wrote these lines at the root of the gradle file.



assembleRelease.doLast {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}


However, Gradle won't even sync, throwing this error:




Could not get unknown property 'assembleRelease' for project ':myApplication' of type org.gradle.api.Project.




I then tried to create a task like seen in this other SO question:



task notification() {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}
build.finalizedBy(notification) //


This doesn't throw any error but no notification is showing.



Why did my attempts failed ? How could I achieve my goal ?



If possible, information about how I should have searched to find this information myself is very welcome.










share|improve this question















I would like to get a notification when Gadle finish to build my app,



Please note that I'm not very familliar with Gradle except for the usual statements used in Android Studio but I'm glad I could learn something.



The best way I've seen so far seems to use announce and build-announcements plugins, as it is stated in this link. Unfortunately it is meant for Gradle in general and I cannot see how to adapt it to Android Studio's builds system. BTW, I'm on windows and have Snarl installed but no clue about how to make it work with Android Studio.



As in the tutorial, I applied both plugins to my app/build.gradle.



I first tried to adapt the code from this SO question. Since there was no real infromation about it, I wrote these lines at the root of the gradle file.



assembleRelease.doLast {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}


However, Gradle won't even sync, throwing this error:




Could not get unknown property 'assembleRelease' for project ':myApplication' of type org.gradle.api.Project.




I then tried to create a task like seen in this other SO question:



task notification() {
announce.local.send "Gradle Info Task", 'Running'
println gradle.gradleVersion
announce.announce("helloWorld completed!", "local")
}
build.finalizedBy(notification) //


This doesn't throw any error but no notification is showing.



Why did my attempts failed ? How could I achieve my goal ?



If possible, information about how I should have searched to find this information myself is very welcome.







android android-studio gradle notifications android-gradle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 19:32

























asked Nov 10 at 12:27









Dan Chaltiel

1,53121838




1,53121838












  • Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
    – Dan Chaltiel
    yesterday


















  • Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
    – Dan Chaltiel
    yesterday
















Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
– Dan Chaltiel
yesterday




Anyone downvoting this question should at least explain why... How am I supposed to improve it if I don't know what is wrong ?
– Dan Chaltiel
yesterday












1 Answer
1






active

oldest

votes

















up vote
0
down vote













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
} else if (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}





share|improve this answer























  • Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
    – Dan Chaltiel
    Nov 10 at 19:32












  • @DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
    – Martin Zeitler
    2 days ago












  • As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
    – Dan Chaltiel
    yesterday










  • @DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
    – Martin Zeitler
    yesterday












  • Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
    – Dan Chaltiel
    yesterday













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238948%2fhow-to-get-a-notification-when-android-studio-finish-a-build%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













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
} else if (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}





share|improve this answer























  • Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
    – Dan Chaltiel
    Nov 10 at 19:32












  • @DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
    – Martin Zeitler
    2 days ago












  • As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
    – Dan Chaltiel
    yesterday










  • @DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
    – Martin Zeitler
    yesterday












  • Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
    – Dan Chaltiel
    yesterday

















up vote
0
down vote













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
} else if (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}





share|improve this answer























  • Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
    – Dan Chaltiel
    Nov 10 at 19:32












  • @DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
    – Martin Zeitler
    2 days ago












  • As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
    – Dan Chaltiel
    yesterday










  • @DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
    – Martin Zeitler
    yesterday












  • Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
    – Dan Chaltiel
    yesterday















up vote
0
down vote










up vote
0
down vote









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
} else if (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}





share|improve this answer














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
} else if (task.name == "assembleRelease") {
task.finalizedBy finalizeBuild
}
}






share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered Nov 10 at 17:57









Martin Zeitler

11.1k33559




11.1k33559












  • Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
    – Dan Chaltiel
    Nov 10 at 19:32












  • @DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
    – Martin Zeitler
    2 days ago












  • As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
    – Dan Chaltiel
    yesterday










  • @DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
    – Martin Zeitler
    yesterday












  • Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
    – Dan Chaltiel
    yesterday




















  • Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
    – Dan Chaltiel
    Nov 10 at 19:32












  • @DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
    – Martin Zeitler
    2 days ago












  • As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
    – Dan Chaltiel
    yesterday










  • @DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
    – Martin Zeitler
    yesterday












  • Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
    – Dan Chaltiel
    yesterday


















Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
– Dan Chaltiel
Nov 10 at 19:32






Thank you for your answer but I already have added these 2 plugins, as stated in the question. I also know all these things as I obviously read all links I provided. I deited my question so my platform is known. If you want to help me, could you please provide som answers to my questions ? Or maybe some code ?
– Dan Chaltiel
Nov 10 at 19:32














@DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
– Martin Zeitler
2 days ago






@DanChaltiel if the project does not have any assembleRelease task, it might be lacking a buildType with name release. there also is no task build. assembleDebug & assembleRelease are the last tasks.
– Martin Zeitler
2 days ago














As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
– Dan Chaltiel
yesterday




As I said, I only know basics about gradle and even never had to use it outside of AS, hence I am here for help. I think your answer, even after edits, is more thought for gradle-aware people so I'm afraid I'm still as lost as at start. I think I use the default config of Android Studio with both debug and release buildTypes and I don't even know where to look at to add a task without blasting everything out (and I couldn't find any simple tutorial). Your code doesn't work when I insert it at the bottom of app/build.gradle, was it the right place ? Could you elaborate a little (ELI5) ?
– Dan Chaltiel
yesterday












@DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
– Martin Zeitler
yesterday






@DanChaltiel the names of the tasks may vary. just run ./gradlew tasks to get the correct names. or check the build log, what the task at the very bottom is. without build-types, it might be assemble.
– Martin Zeitler
yesterday














Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
– Dan Chaltiel
yesterday






Your code is finally working, but only the println part. The command of your last comment returned all expected tasks included assemble, assembleDebug & assembleRelease. Still no clue why Gradle won't recognise them anyway. I think my very problem is that the announce plugin doesn't work and the Snarl doc is not much of help. Is there any config I should know about to connect Gradle to Snarl ? I couldn't find any doc about it...
– Dan Chaltiel
yesterday




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238948%2fhow-to-get-a-notification-when-android-studio-finish-a-build%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values