bobbymcsteels
bobbymcsteels

Reputation: 21

Android Gradle - Implementing shared .aar files in addition to flavor specific .aar files

I've been trawling the net looking for a solution to this and have come kinda close but not solved my problem.

I have 3 flavors, Im trying to implement 3 different version of the same .aar files based which flavor is being run in addition to some aar files that are used in each flavor. The .aar files all have the same name but are setup specifically to work for a specific packagename.

I have created 3 Android Studio module/libraries with those .aar in the /libs folder and these are dependencies of /app.

app/

flav1Module/

flav2Module/

flav3Module/

Am I missing a way to implement these modules within the productFlavor setup as in something along these lines

    flavor1{
       applicationIdSuffix ".flav1"
       resValue "string", "app_name", "App-Flav1"
  }
    flavor2{
       applicationIdSuffix ".flav2"
       resValue "string", "app_name", "App-Flav2"
  }
    flavor3{
       applicationIdSuffix ".flav3"
       resValue "string", "app_name", "App-Flav3"
  }
}



flavor1Implementation project(':flav1Module')
flavor2Implementation project(':flav2Module')
flavor3Implementation project(':flav3Module')


Upvotes: 0

Views: 876

Answers (1)

bobbymcsteels
bobbymcsteels

Reputation: 21

Found what seems like a hacky answer to this by doing the following:

  • Added all .aar files to the libs folder and renamed each of the .aar files for flavor1/2/3 accordingly (example "flav1arr.arr")
  • In build.gradle added the following for each flavor flavor1Implementation "name:'flav1aar', ext:'aar'"

This did the trick. I'd be open to any better way to do this though.

Upvotes: 0

Related Questions