Phone and tablet Module vs Android Library

5.2k views Asked by At

I want to make a separate module so I can share it between projects. The module is going to have android components. So upon creating a new module the options are Phone & Tablet module and Android Library. I wanted to know what's the difference between the two. thanks

2

There are 2 answers

0
ישו אוהב אותך On BEST ANSWER

What is Module? From the Add a Module for a New Device documentation:

Modules provide a container for your app's source code, resource files, and app level settings, such as the module-level build file and Android manifest file. Each module can be independently built, tested, and debugged.

What is Android Library? From Create an Android Library documentation:

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module. Unlike JAR files, AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.

You can't access the components from one module to another module. So, if you need to share components between projects, you need to create Android library. But please remember, you can't run the library. You only can access and use it from the module. Furthermore, you can use Gradle Android Maven plugin to install your library locally.

0
josedlujan On

Check the official doc

Resume: Modules provide a container for your app's source code, resource files, and app level settings, such as the module-level build file and Android manifest file. Each module can be independently built, tested, and debugged.

Android Studio uses modules to make it easy to add new devices to your project. By following a few simple steps in Android Studio, you can create a module to contain code that's specific to a device type, such as Android Wear or Android TV. Android Studio automatically creates module directories, such as source and resource directories, and a default build.gradle file appropriate for the device type. Also, Android Studio creates device modules with recommended build configurations, such as using the Leanback library for Android TV modules.