How to create a library project in Android Studio and an application project that uses the library project

android-studio

Solution

To create a library:

File > New Module

select Android Library

To use the library add it as a dependancy:

File > Project Structure > Modules > Dependencies

Then add the module (android library) as a module dependency.

Run your project. It will work.

Problem

How do I create an Android Library Project (e.g. com.myapp.lib1) and the application project (e.g. com.myapp.app) and make the build system include com.myapp.lib1 on the application project? I went to the Project Structure -> Modules -> My App project and added a dependency to the lib project. IntelliJ now can recognize classes from the lib project when used in the app project, but when I run the app project, there are errors like: ``` Gradle: error: package com.myapp.lib1 does not exist ```

Original source

Related problems