I'm new to the gradle build system and IntelliJ.
So 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
Had the same question and solved it the following way:
Start situation:
Target: want to add a module named
dataformats
Java Library
)Make sure your
settings.gradle
look like this (normally automatically):include ':frigoshare', ':frigoShare-backend', ':dataformats'
Make sure (manually) that the
build.gradle
files of the modules that need to use your library have the following dependency:dependencies { ... compile project(':dataformats') }
For Intellij IDEA (and Android Studio) each library is a Module. Think of a Module in Android Studio as an equivalent to project in Eclipse. Project in Android Studio is a collection of modules. Modules can be runnable applications or library modules.
So, in order to add a new android library project to you need to create a module of type "Android library". Then add this library module to the dependency list of your main module (Application module).