Android Studio完成构建后如何获得通知? [英] How to get a notification when Android Studio finish a build?

查看:238
本文介绍了Android Studio完成构建后如何获得通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Gadle完成构建应用程序后收到通知,

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

请注意,除了Android Studio中使用的常用语句外,我对Gradle并不十分熟悉,但很高兴我能学到一些东西.

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.

到目前为止,我见过的最好的方法似乎是使用announcebuild-announcements插件,如

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.

与本教程中一样,我将两个插件都应用于了我的app/build.gradle.

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

我首先尝试修改这个SO问题中的代码.由于没有真正的信息,因此我在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")
}

但是,Gradle甚至无法同步,并引发以下错误:

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

无法获得类型为org.gradle.api.Project的项目':myApplication'的未知属性'assembleRelease'.

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.

为什么我的尝试失败了?我如何实现我的目标?

如果可能的话,非常欢迎您提供有关如何自行搜索该信息的信息.

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

推荐答案

实现所需需求的最简单方法:

The easiest way to achieve what you need :

在Android Studio中,进入Preferences > Appearance & Behavior > Notifications,转到Gradle Build(记录)并选中朗读"框.

In Android Studio, go into Preferences > Appearance & Behavior > Notifications, go down to Gradle Build (Logging) and check the Read aloud box.

这将说明Gradle构建在完成后的x分钟和x秒内完成.

This will speak Gradle build finished in x minutes and x seconds when your build is complete.

这篇关于Android Studio完成构建后如何获得通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆