Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we have multiple apps in one Android Studio project?

I am using Android Studio for developing Android apps. But I have heard in Android Studio it is better to have only one app in a single (one project per app) if that is right, then it will be very wasteful to open many frames for many projects. But when I searched I found that

  • Android Studio project = Eclipse workspace
  • Android Studio module = Eclipse project

Now, if this is true, it means that Android Studio also can support a multi-app project. If yes, then, is every app in Android Studio independent like in Eclipse (i.e. they do not disturb each other by sharing any file or setting)? Or can we have many apps in a single project? If we can then is there any point to take care of?

Thanks!

like image 605
Bahramdun Adil Avatar asked Sep 06 '15 03:09

Bahramdun Adil


People also ask

Can I open two projects in Android Studio?

To open multiple projects simultaneously in Android Studio, go to Settings > Appearance & Behavior > System Settings, in the Project Opening section, choose Open project in new window.

Can we work together in Android Studio?

Collaboration Features Provided by Android Studio ExtensionsAccess the extensions marketplace in Android Studio (Android Studio >> Preferences >> Plug-ins) and quickly run a search for "collaboration." A list of extensions with different collaboration features will return.


1 Answers

Yes, you have two options:

Option 1: Create an addition app module

  1. First create your standard Phone & Tablet Android project, including the auto-generated app module.
  2. Add a new app module: File > New > New Module ... > Phone & Tablet Module
  3. Complete the wizard and name your Application app2 for instance.

Now you'll have both app and app2 in the same project.

To actually run app2 you first need to select it in the pull-down menu in the top toolbar of Android Studio, next to the Start and Debug icons. You can also do this though Run Configurations: Run > Run... > Edit Configurations... and modifying Module.

Option 2: Create an addition library module

This is ideal for creating a separate library that is isolated from the app, and can be shared across more apps (or other projects):

  1. Add a new library module: File > New > New Module ... > Java Library.
  2. Complete the wizard and give your library a good name, like libgoodstuff.

Now libgoodstuff and app will reside in the same project.

To make app sources depend on libgoodstuff, you first have to add the library module to the project settings.gradle to look something like this:

include ':app', ':libgoodstuff' 

Then in app/build.gradle you have to depend on the library module like this:

apply plugin: 'com.android.application'  ··· dependencies {     ···     implementation project(path: ':libgoodstuff')     ··· } ··· 
like image 160
Stephan Henningsen Avatar answered Sep 22 '22 15:09

Stephan Henningsen