I have added the .aar files to libs folder in the sub-project. And have given the repositories as:
repositories {
 mavenCentral()
    mavenLocal()
    flatDir {
        dirs 'libs'
    } 
in the build.gradle of this sub-project. Do I need to add dependencies in Main project's build.gradle also? If yes, how should that be done?
You are adding a aar file in libs folder.
The aar file doesn't contain the dependencies, then you have to add these dependencies also in the main project.
In your module1/build.gradle you should have something like:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.android.support:appcompat-v7:22.2.1') //for example
    //..
 }
In your mainModule/build.gradle you have to add all the dependencies used by your module1.
dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile(name:'fileName',ext:'aar')
        compile('com.android.support:appcompat-v7:22.2.1') //for example
        //...
     }
In the repositories of your module: app
repositories {
    flatDir {
        dirs 'libs'
    }
}
Add the following in the dependencies of your module: app In the case that your have both a JAR and an AAR file, do the following.
dependencies 
{
  implementation (name: '***library name***', ext: 'aar')
  implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'], )
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With