Nima
Nima

Reputation: 6563

set applicationIdSuffix depending on productFlavor

We have 2 productFlavors (testServer, liveServer) and 2 build types (debug, release).

Due to existing API keys, I have to append package names based on buildType + productFlavor.

For example something like:

buildTypes {
  debug {
   applicationIdSuffix '.dbg' + (testServer ? '.test' : '.live')
  }

  release {
   applicationidSuffix '' + (testServer ? '.test')
  }  
}

is this possible? how?

Upvotes: 10

Views: 13374

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13466

productFlavors {
    testServer {
        applicationId = "com.example.my.pkg.test"
    }
    liveServer {
        applicationId = "com.example.my.pkg.live"
    }
}

buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }
}

For more information, take a look at the Android documentation regarding application ids.

Upvotes: 20

Related Questions