Android Studio - several Android applications with common dependencies in one project

I have two different Android applications A and B. A and B are modules in one project

Both have a dependency on library module Z, which itself depends on two other library modules X and Y

  • A β†’ Z
  • B β†’ Z

Z β†’ X, Y

Now the accepted answer to this question suggests that there can not be several applications in one Android Studio project.

It is strange that I can create these two applications (in the same Android studio project) and run them pretty well on my phone. Did I miss something obvious here?

Can a single Android studio project contain multiple applications?

  • If the answer is NO, why?
  • If the answer is YES, are there any catches?
+7
android android-studio project-structure
source share
1 answer

There can really be several applications in one Android project, although you can argue about the benefits of having multiple applications in one project if they are not connected.

In any case, it is quite reasonable if you have several versions of the same application with some differences between them (target devices, branding ...). In this case, the Gradle build system allows you to have build options (each build option is a combination of product taste and build type). According to the official documentation ( Configuring Gradle Build> Working with Build Options ):

The build system uses products to create different product versions of your application. Each version of your application may have different features or device requirements. The build system also uses build types to apply different build and packaging settings for each version of the product. Each combination of product flavor and assembly type is an assembly option. The build system generates a different APK for each build option of your application.

+3
source share

All Articles