The way to Keep away from Dependency Conflicts in Android Multi-Module Apps | by Waseef Akhtar | Jan, 2023 | Whole Tech

PROJECT NEWS  > News >  The way to Keep away from Dependency Conflicts in Android Multi-Module Apps | by Waseef Akhtar | Jan, 2023 | Whole Tech

very practically The way to Keep away from Dependency Conflicts in Android Multi-Module Apps | by Waseef Akhtar | Jan, 2023 will lid the newest and most present steering nearly the world. strategy slowly subsequently you comprehend with out problem and accurately. will lump your information proficiently and reliably

As an Android developer, you might have skilled the frustration of managing dependencies in your venture. It may be particularly difficult when you’ve gotten a number of modules in your venture, as it is easy to finish up with completely different variations of the identical dependency in numerous modules. This may result in conflicts and unpredictable habits.

One solution to resolve this downside is to create a buildSrc module in your venture. He buildSrc module is a particular module used to retailer your venture’s construct logic, together with dependencies. By preserving your dependencies in a single place, you possibly can make sure that all modules in your venture use the identical model of a dependency.

In fact, there are alternative ways to unravel this downside, and which strategy is greatest for you’ll rely in your particular wants and preferences.

After I revealed this weblog put up, I believed that most individuals as of late favor to make use of the Gradle launch catalog. I personally discover buildSrc simple to take care of.


To create a buildSrc module, you will have to do the next:

  1. Open your venture.

2. Within the Mission panel, change the show out of your Android information to Mission Information.

Whenever you view information as Android information, they’re organized by operate inside the Android working system, corresponding to by exercise or service. Whenever you view information as venture information, they’re organized by their location on the file system.

That is an instance of how the information would seem if you view them as venture information: they’re organized by their location within the file system. 👇

3. Now, create a brand new listing from the foundation folder of your venture, and provides it a reputation buildSrc.

4. Now we have to create a brand new gradle file inside this listing.

This may assist convert this from a easy listing to a module. This can even assist construct this module’s dependencies into our different gradle information in numerous modules.

By changing a listing to a module, you possibly can create a separate unit of code inside your venture that may be compiled and run independently. This may be helpful for organizing your venture and creating reusable code that may be shared throughout a number of functions or libraries.

That is the way you do it:

a) Create a brand new file and provides it a reputation construct.gradle.kts.

b) Paste the next code into your new file:

c) Synchronize the venture in order that the brand new modifications work throughout all the venture.

If you happen to discover, this provides just a little sq. blue icon to the underside proper of your buildSrc folder icon and in addition add the construct listing inside it.

Which means that the sync was profitable changing the listing to a module.

5. It is time to add dependencies!

a) in his buildSrccreate a brand new src/fundamental/kotlin listing.

That is used to retailer all your Kotlin supply code for this module, together with how we’ll declare dependencies.

6. Lastly, contained in the src/fundamental/kotlin listing, create a brand new Kotlin object class known as, Depsboth Dependencies.

7. Paste the dependencies you need to your venture.

Make the dependency model have its personal variable. This ensures that we use the identical model for all comparable dependencies. For instance, compose-ui, compose-ui-tooling, compose-foundation, and so on. all use the identical model, so you will not run into conflicts or errors utilizing completely different variations for various dependencies.

8. Now all you want is to go to the opposite modules gradle file and change their already outlined dependencies with those we outlined within the Deps.kt object class

For instance:

implementation 'androidx.compose.ui:ui' may be changed by implementation(Deps.composeUi)

And… congratulations! You now have a extra scalable, structured, and maintainable venture to your Android app.


By preserving your dependencies on the buildSrc module, you possibly can keep away from the danger of sustaining completely different variations of dependencies in numerous modules. This may make it simpler to handle your venture and make sure that every part works as anticipated. Additionally, it might probably make it simpler to refactor your code and make modifications, because you solely have to replace dependencies in a single place.

Typically, create a buildSrc The module is an easy and efficient solution to handle dependencies in your Android venture. It may well prevent time and trouble in the long term and enable you to construct a extra steady and dependable software.

I hope the article very practically The way to Keep away from Dependency Conflicts in Android Multi-Module Apps | by Waseef Akhtar | Jan, 2023 provides sharpness to you and is beneficial for complement to your information

How to Avoid Dependency Conflicts in Android Multi-Module Apps | by Waseef Akhtar | Jan, 2023