Android studio add external project to build.gradle

Assuming that Some Other Folder is a gradle project you could add something like the following to your settings.gradle file:

include ':module1'
project(':module1').projectDir = new File(settingsDir, '../Project B/Module 1')

You have to put in your file settings.gradle this lines:

include ':module2'
project(':module2').projectDir = new File(settingsDir, '../Project 2/Module2')

Then you have to add in your builde.gradle (Module: app) in the dependencies tree, this line:

implementation project(':module2')

or go into the Project Structure > app > Dependencies, click on Add, choose 3 Module Dependencies and select your module