Can we have multiple applications in one Android Studio project?

I am using Android Studio to develop Android applications. But I heard that in Android Studio it is better to have only one application in one (one project per application), if this is correct, 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 so, that means Android Studio can also support a project with multiple applications. If so, is each application in Android Studio independent, as in Eclipse (i.e. they do not interfere with each other, sharing any file or setting)? Or do we have many applications in one project? If then can we take care of him?

Thanks!

+28
android android-studio
source share
4 answers

Yes, you can create an additional application module:

  • First, create a standard Android phone and tablet project, including an automatically created app module.
  • Add a new application module: File> New> New module ...> Phone and tablet module
  • Finish the wizard and provide the app2 app name .

You will now have both applications and app2 in the same project.

To really launch app2 , you first need to select it from the drop-down menu on the top toolbar of Android Studio, next to the Start and Debug icons. You can also do this, although Run Configurations: Run> Run ...> Edit Configurations ... and modifying Module.


Or instead, you can create an additional library module (for individual code or shared code shared among applications and / or other projects):

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

Now libgoodstuff and the application will be in the same project.

+27
source share

Yes, you can. Inside the project, if you want to create a new application, follow these steps:

Now you can run any application. This is a great way to share code between two applications, as it allows you to maintain and grow your libraries in one place.

enter image description here

enter image description here

+7
source share

You can have several application modules in one Android Studio project. Having said that, I have not yet found a reason to define several application modules in the project.

  • If you need a different version of the same application, the Gradle build option is efficient enough to satisfy perhaps 99% of use cases (I have a project with a dozen options, each with its own / res code).
  • If you write different applications, then it is better to make each of your own projects so that the applications do not accidentally change each other's behavior.

I'm not sure what you mean by β€œevery application in Android Studio independent as Eclipse”, but each module is its own world by default unless dependencies on other modules are explicitly defined.

+4
source share

Adding this as an answer since I don't have enough reputation for comment yet.

The answer to your question is check the question that I raised. Is this the same boat you were in?

TL; DR

I was able to have several applications in one Android Studio project, create and run them without any problems. Another member confirmed my claim in the comments on the Question.

@Android Studio Pros: Please check the link above and add your ideas. This seems like a confusing aspect.

My take

I think I agree with @Kai's answer. But there are cases when we want several applications to have common dependencies in the library and do not want to duplicate library dependencies. There would not be many applications in order if the common library dependencies have ONLY common code and nothing else. Separate modules contain separate code associated with the application, and one where differentiation takes place.

+3
source share

All Articles