1'hafs
1'hafs

Reputation: 579

How to get applicationId after all suffixes added in android app/build.gradle

How to get applicationId after all suffixes added in android app/build.gradle

I tried to use it as below, but the application id is null, we are setting the applicationId to default config from app/build.gradle, I assume it has executed later than we set the resValue, also I need the applicationId when it is completely appended with all suffix from flavor and buildType.

app/build.gradle

android {
     defaultConfig.applicationId "com.companyname.appname"
}

util/build.gradle

android {
     defaultConfig {
         resValue "string", "freshchat_file_provider_authority", applicationId + ".provider"
     }
}

Share if anybody can support about this.

Upvotes: 2

Views: 1066

Answers (1)

1'hafs
1'hafs

Reputation: 579

We can make applicationId via accessing current flavorName and buildType by placing the below code in app/build.gradle android closure as below.

    applicationVariants.all { variant ->
        def flavorName = variant.flavorName
        def buildType = variant.buildType.name
        def applicationIdMade = defaultConfig.applicationId + ".$flavorName.$buildType"
        println applicationIdMade // Use as you require
    }

Upvotes: 1

Related Questions