As we all know, the build of Android Studio is based on Gradle, and Gradle is based on groovy, groovy is Java-based
Android Studio's Gradle itself is based on groovy, so the environment is not built to say much.
Groovy Language Basics
1. Note: Use the same as Java//,/** **/
2. Groovy statements can end without semicolons
3. Supports dynamic types, that is, when declaring variables, you can specify no type
4. Function definition:
Def getchanneloption () { return "XX"}
5. String Support:
The contents of single quotation marks strictly correspond to the string in Java and do not escape the $ symbol
def singlequote= ' I am $ Dolloar ' //output is I am $ dolloar
The content of the double quotation mark "" is a bit like that of the scripting language, and if there is a $ number in the character, then it evaluates the $ expression first.
def doublequotewithoutdollar = "I am one dollar"//output I am one dollar def x = 1 def doublequotewithdollar = "I am $x Dolloar "//Output I am 1 dolloar
Three quotes "' xxx ' in the string support arbitrary line breaks such as
def multielines = "Begin line 1 line 2 End"
Finally, in addition to each line of code, there is no need to add parentheses to the function call in groovy. Like what:
println("test") ---> println "test"
Groovy and Gradle applications in Android