Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Multiple android apps with common dependencies in a single project

I have two different android apps A and B. A and B are modules in the same project

Both have a dependency on a 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 says that a single Android Studio project cannot have multiple apps.

Strangely I am able to build these two apps (in a single android studio project) and run them on my phone pretty well. Am I missing something obvious here ?

Can a single android studio project contain multiple apps ?

  1. If the answer is NO, why ?
  2. If the answer is YES, are there any catches ?
like image 310
acthota Avatar asked Nov 04 '15 11:11

acthota


People also ask

Can we have multiple apps in one Android Studio project?

You can definitely have multiple app modules in the same Android Studio project.

How can two Android apps run in the same process?

Step 1: Tap & hold the recent button on your Android Device –>you will see all the recent list of applications listed in chronological order. Step 2: Select one of the apps you wish to view in split screen mode –>once the app opens, tap & hold the recent button once again –>The screen will split into two.

Can I open two instances of Android Studio?

It's possible to have multiple versions of Android Studio installed simultaneously. When we offer canary builds (or even beta builds) of the next version of the IDE, you may want to install the new version without replacing your existing stable install.


1 Answers

A single Android project can indeed have multiple apps, although you could argue about the benefits of having several apps in a single project if they are unrelated.

Anyway, this is perfectly reasonable in case you have several versions of the same app with some differences among them (target devices, branding...). In that case the Gradle build system allows you to have build variants (each build variant being a combination of a product flavor and a build type). According to the official documentation (Configuring Gradle Builds > Work with build variants):

The build system uses product flavors to create different product versions of your app. Each product version of your app can have different features or device requirements. The build system also uses build types to apply different build and packaging settings to each product version. Each product flavor and build type combination forms a build variant. The build system generates a different APK for each build variant of your app.

like image 85
José González Avatar answered Oct 23 '22 10:10

José González