This question can have two different answers based on the meaning of the word needed.
First (the real one)
Assuming your project has currently those files, if your question is:
Should I commit these files on my Git repo?
The answer is yes, all of them, and I'm explaining why:
root
- build.gradle -> defines the configuration for all the Gradle modules in your project (e.g. use the same remote repositories to download some Gradle plugins)
- gradle.properties -> defines some optional flags used when building the app (e.g. enabling the incremental KAPT, enabling the AndroidX jetifier)
- gradlew -> invokes the Gradle wrapper (which can be found under
gradle/wrapper/gradle-wrapper.jar
) to avoid to have Gradle installed when building your project on Darwin/Linux
- gradlew.bat -> the same of gradlew but for Windows
- settings.gradle -> defines the list of modules which are part of your project
app/
- app/build.gradle -> defines the configuration only for your app module (e.g. its build types, its flavors, its version code and version name)
- app/proguard-rules.pro -> defines the obfuscation rules when your app enables the minification
gradle/
- gradle/wrapper/gradle-wrapper.jar -> provides the same version of the Gradle wrapper jar for all the users. This is very important because it forces the users to use the same version of the Gradle wrapper to compile your app
- gradle/wrapper/gradle-wrapper.properties -> same as above, it defines which version of the Gradle wrapper you need
Second (the useless one)
Now, I'll give you the answer to the question:
Are these files strictly needed to compile an Android project?
To successfully compile an Android project with Gradle you just need the root build.gradle
if you have Gradle installed on your machine or build.gradle
+ the wrapper files if you have not Gradle installed on your machine.
Theoretically you can:
- put your application code in the root project and that avoids you one
build.gradle
and settings.gradle
- disable the obfuscation and that avoids you
proguard-rules.pro
- remove
gradle.properties
and set the properties via command line
Obviously this solution won't happen on a real project scenario.