Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way of create and test a library project in Android Studio to share in any project?

In Android Studio 1.0.1 you only have the initial option of create a new project but not a new library.

I would like create a library that I can share with multiple and future apps.

Must I create a new project and create library modules inside?

Can create only a library project?

If a library only have a custom view... How I testing with AndroidTest using an Activity? (Activity should not compile into library)

Thanks.

like image 784
Mou Avatar asked Dec 18 '14 08:12

Mou


People also ask

What is Android Studio for testing?

Android Studio is designed to make testing simple. It contains many features to simplify how you create, run, and analyze tests. You can set up tests that run on your local machine or instrumented tests that run on a device. You can easily run a single test or a specific group of tests on one or more devices.

What is an Android shared library?

Similar to the traditional Linux model, shared libraries in Android are relocatable ELF files that map to the address space of the process when loaded. To save memory and avoid code duplication, all shared objects shipped with Android are dynamically linked against the Bionic libc library [23].

What is .AAR file in Android Studio?

Android Studio can be used to create an Android archive file (*. aar) that can contain classes and methods that make use of Android classes and related files. Like creating the Jar file, an Android project must be created first, then the Android library module can be created and added.


1 Answers

You are right, there is no option to create a library project using the initial wizard. The way I do it is to create an app module (using the wizard) and then add Android Library module using File -> New Module.

Most of the time I end up keeping the app module for testing and as an usage example of the library. I put all my tests (and other parts required for testing, like Activities) inside an app module to keep them separate of the library itself.

You can remove the initial app module by removing its name from settings.gradle and deleting the module directory.

like image 175
atok Avatar answered Oct 08 '22 07:10

atok