The problem with preinstalling gradle is which version?
The official recommended way to run gradle is to use gradlew, the “gradle wrapper” which you’re expected to have committed into your repository, as that defines which version of gradle you use in your project and gradlew installs that version.
See previous discussion at How to update Grade version from script
Also official docs: https://docs.gradle.org/current/userguide/gradle_wrapper.html