Skip to content

Gradle Build Examples

Ryan Suzuki edited this page Mar 27, 2022 · 1 revision

Flavor variants

application's build.gradle

For most use-cases, this should be sufficient.

android {
  ...

  flavorDimensions "app"
  productFlavors {
    google {
      applicationIdSuffix ".google"
    }

    amazon {
      applicationIdSuffix ".amazon"
    }
  }
  
  dependencies {
    amazonApi ("com.github.rjsuzuki:billingz:v2.1.0") {
        exclude module: "google"
    }
    googleApi ("com.github.rjsuzuki:billingz:v2.1.0") {
        exclude module: "amazon"
    }
  }
  ...
}

Multi-module

For more unique use-cases when a direct call to a billing library's model or function is required, splitting the project into two separate modules will allow type casting from the Billingz library base model, such as Productz, into AmazonProduct or GoogleProduct. Those variations will contain the original data passed by the relevant billing library.

  • app-module
  • amazon-module
  • google-module
Clone this wiki locally