Before Firebase Analytics became available we use a multi flavour, multi build type Android Gradle project setup, and supply a different GTM container ID for each build variant,
The container ID is derived from the container file name, as you surmised. To use a per-build variant you can use gradle copy task to stage the correct container.
This is how we set up our Gradle multi-flavor project to use different GTM container for each build variant:
/
|_app/
|_src/
|_flavor1/
| |_google-services.json # Google services config for debug
| |_release/
| |_google-services.json # Google services config for flavor1
|_flavor1Release/
| |_assets/
| |_containers/
| |_GTM-ABCXY1.json # GTM container for flavor1
|
|_flavor2/
| |_google-services.json # Google services config for debug
| |_release/
| |_google-services.json # Google services config for flavor2
|_flavor2Release/
| |_assets/
| |_containers/
| |_GTM-ABCXY2.json # GTM container for flavor2
|
|_debug/
| |_assets/
| |_containers/
| |_GTM-ABCXY3.json # GTM container for debug
|
|_main/
|_res/
|_java/
Assuming you have 2 flavors flavor1
and flavor2
, and want to have 3 GTM containers, 1 shared for debug build of both flavors, and 1 each for release build of each flavor.
GTM will connect to the FA dashboard of the project specified by your google-services.json
. Multi-flavor multi-build type google-services.json
support has been available since plugin version 2.1.0 [1]