Migrating your app Gradle file from Flavors to Flavors & Dimensions
If your project has different flavors and you’ve recently updated to gradle plug-in version to 3.0 or above, you may have received the following error message when making a gradle build: “Error:All flavors must now belong to a named flavor dimension”.
So in this article we will discuss how to migrate your project to the changes of new gradle updates.
Initially you can see in picture 1 my project gradle file has gradle plug-in version as 2.3.3
Also I have 3 flavors added in my app gradle file which is seen in picture 2
And when the Gradle version is updated to a new version in my project it is updated to 3.1.4, you can see following error message when making a gradle build: “Error:All flavors must now belong to a named flavor dimension” can be seen in picture 3
So now we create a new dimension lets name it firstdimension and each flavor in our app must be associated with a dimension so referencing all the flavors in our gradle file to firstdimension then build the project now the error should disappear. can be seen in picture 4
So What is Flavor dimension?
“These dimensions will actually allow us define different groups of flavors. Gradle creates combination of build variants between these groups for us. In the next article we will see how to build different variants with the combination of different flavors and dimensions”.
Done! for now. My first blog post ever, hope it was a good!