java - build gradle variables to be used in code depending on flavor AND build type -



java - build gradle variables to be used in code depending on flavor AND build type -

is there way utilize variables build.gradle in code, dependent on flavor , buildtype?

in illustration here: is possible declare variable in gradle usable in java? new resource value depends on if debug or release build type.

what have 1 variable each possible buildvariant.

so like:

flavor1debug => resvalue "string", "app_name", "app 1 debug" flavor1release => resvalue "string", "app_name", "app 1" flavor2debug => resvalue "string", "app_name", "app 2 debug" flavor2release => resvalue "string", "app_name", "app 2"

is there nice way either through build.gradle or way doesn't included switches or if else statements?

in build.gradle app, 1 way accomplish be:

buildtypes { debug { productflavors.flavor1.buildconfigfield "string", "app_name", "\"app 1 debug\"" productflavors.flavor2.buildconfigfield "string", "app_name", "\"app 2 debug\"" } release { productflavors.flavor1.buildconfigfield "string", "app_name", "\"app 1\"" productflavors.flavor2.buildconfigfield "string", "app_name", "\"app 2\"" } }

note you'll want define productflavors{} block before buildtypes.

java android android-studio android-gradle

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -