Reputation: 877
I'm trying to print out a variable (example:${project.projectDir}) when I sync my Android Studio project with build.gradle, because I need to see the variable's value to make my task definition working properly.
I searched stack overflow and then followed others' suggestion, I tried follows:
project.logger.debug("@@@@@@@@@ ${project.projectDir}")
System.out.println("@@@@@@@@@ ${project.projectDir}")
println "@@@@@@@@@ ${project.projectDir}"
But none of above working, the "Sync" pane at the bottom does not show anything. Since Android studio does not provide "debugging gradle" function. So what is the easy way to know a variable value defined/pre-defined in build.gradle?
Upvotes: 3
Views: 4832
Reputation: 296
Create task inside project/module level build.gradle file, then add this code
task sample { project.logger.lifecycle('my info message') }
to build ./gradlew sample
(Mac)
It will print inside android studio terminal.
Output:
Upvotes: 5