Android Studio - Library module inside library module

Viewed 131

I'm trying to setup a project in this way:

MainModule -> LibraryModule1 -> LibraryModule2
↓                                      ↑
----------------------------------------

Every module 'sits' in a different git repository.
MainModule git repository includes LibraryModule1 as a submodule.
LibraryModule1 git repository includes LibraryModule2 as a submodule.

The Android perspective:

In summary (from the end):
LibraryModule2 is an android library (com.android.library)
LibraryModule1 is an android library (com.android.library) which has LibraryModule2 as module dependency
MainModule is an android application (com.android.application) which has LibraryModule1 as module dependency (MainModule should 'know' about LibraryModule2 too)

The main goal is to to be able to include LibraryModule1 in other applications too.

Here's the gradle files:

LibraryModule1 settings.gradle:

include ':app', include ':library2'
project(':library2').projectDir = new File('path_to_library_2')

LibraryModule1 build.gradle:

dependencies {

    api project(path: ':library2')
}

MainModule settings.gradle:

include ':app', ':library1'
project(':library1').projectDir = new File('path_to_library_1')

MainModule build.gradle:

dependencies {

    implementation project(':library1')
}

When trying to sync gradle, a problem occurs:

A problem occurred evaluating project ':library1'. Project with path ':library2' could not be found in project ':library1'.

Is there a way to solve it without specifically include LibraryModule2 in MainModule?

0 Answers
Related