Since it was an irregular folder structure in React Native's Android project, I will show you how to handle it well with Gradle. In case of subfolders or folders in the same hierarchy, it can be realized by Multi-project with Gradle.
myapp/
android/★ root project
build.gradle
settings.gradle ★ Edit this
app/★ App project
build.gradle
library/
android/★ Library project
build.gradle
settings.gradle
include ':app'
//Add from here
include ':library'
project(':library').projectDir = file('../../library/android')
//Add up to here