I've been using Android Studio for years, but only recently have I started seeing files with the *.toml
suffix. I see that they work with gradle files, but I have been migrating to kotlin instead of gradle files (as per new google standards).
I also see that the toml files are automatically being modified. To me that implies that they don't need to be version controlled. But of course they are changed, and git identifies them as modified.
For reference, the currently modified file is gradle/libs.versions.toml
. But occasionally I see others.
So the big question: should I add something like *.toml
to my .gitignore
file? Or will this cause problems down the road (like what?).
This file is important and must be version controlled.
The libs.versions.toml
file is the version catalog and belongs to your build files. Android Studio recently started to use version catalogs by default for new projects. There is also a migration guide for old Android projects available.
A version catalog is a central place to list all versions of the dependencies used in your build. In contrast to the dependencies
block off your gradle files it is just a simple list without any logic involved. The implementations in your dependencies
block then only need to reference an entry of the version catalog if they require that specific dependency, without a need to worry about using the correct version.
Updating versions is something that is now only done in the version catalog, an exercise that is done much more frequently than updating the rest of your build files. Changes are therefore isolated to just that single file.
When you use Android Studio's project settings to update your dependencies then the libs.versions.toml
file is automatically updated. But if you do not check this file in, you'll lose all versions you defined and your gradle files cannot reference the dependencies that were defined and you'll be unable to build your app anymore. It is therefore imperative that you store it together with the rest of your build files and check it in to the version control system you use.