linking to local module in react native module project

my module project structure is as follows:

  • android/
    • somelibrary/
    • settings.gradle
    • build.gradle
  • ios/
  • src/
  • example/

where example is a simple react native project that uses the module of the root project. somelibrary is a react native module as well, which works fine when imported locally in a react native project. It is linked in the settings.gradle file like this:

include ":somelibrary"
project(":somelibrary").projectDir = file("./somelibrary")

and in the build.gradle file like this:

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        flatDir {
            dirs project(':UnityExport').file('libs')
        }
    }
}

When I build the android part of the project using gradle it works fine as well. However, when I import the module in my example project, I get the following error:

Project with path ':somelibrary' could not be found in project ':mainproject'.