mcfly soft
mcfly soft

Reputation: 11665

Setting ApplicationID for every build variant

I need to set my application ID for a build variant.

I have a defaultConfig in my build.gradle, which sets the applicationId

defaultConfig {
    applicationId "mycompany.mainappname"
    minSdkVersion 12

Now I need to set the application ID to "mycompany.mainappname_fullversion". (no dot between mainappname and _fullversion) I need this, because I have published my fullversion to googleplay 4 years ago with this name.

How can I do this ?

I tried to use the applicationIdSuffix syntax in my buildTypes Section to add the suffix, but it also adds me an "." befor the suffix, which is in my case wrong -> "mycompany.mainappname_fullversion._fullversion"

buildTypes {
       full {
          applicationIdSuffix '_fullversion' 

I also tried to set the applicationID with applicationId "mycompany.mainappname_fullversion" in my build section, but i throws errors.

How can I simply set the applicationID to ""mycompany.mainappname_fullversion" in a build ?

Can someone help ?

Upvotes: 1

Views: 1461

Answers (3)

Ahmad Mahmoud Saleh
Ahmad Mahmoud Saleh

Reputation: 169

I know it is a late answer but I'm posting it for anyone who might come across a similar scenario, all you have to do is to add this inside android {} in your App's build.gradle.kts

androidComponents.onVariants {
        // Remove the . between the base applicationId and the applicationIdSuffix that is being automatically added by gradle
        // so we can have this => com.mycompany.mainappname_fullversion instead of this => com.mycompany.mainappname._fullversion 
        it.applicationId.set(it.applicationId.get().replace("mainappname.", "mainappname"))
    }

Upvotes: 0

Seva Alekseyev
Seva Alekseyev

Reputation: 61388

Place a separate manifest in each build variant's directory under src.

Upvotes: 0

Anurag Singh
Anurag Singh

Reputation: 6200

Try removing applicationId from defaultConfig and add applicationId in each of buildTypes

buildTypes {
   full {
      applicationId 'mycompany.mainappname_fullversion' 

Upvotes: -1

Related Questions