GooglePlayServicesComponents icon indicating copy to clipboard operation
GooglePlayServicesComponents copied to clipboard

Invalid macro: _gtm.loadEventEnabled when using Xamarin.GooglePlayServices.TagManager in Android

Open aian23 opened this issue 5 years ago • 2 comments

Xamarin.Android Version (eg: 6.0):

10.1.4.0

Operating System & Version (eg: Mac OSX 10.11):

Windows 10 I'm using VIsual studio 2019

Describe your Issue

Followed every step right:

  1. FB, GA and TM properly set up
  2. Install necessary nugets as stated above.
  3. Put the JSON of the tag manager container inside assets/containers

When I tested in iOS, it went smoothly, however in Android, I kept getting this error: Invalid macro: _gtm.loadEventEnabled

I also encounter this in the device log afterwards:

Failed to load the container. NO default container resource found with resource ID -1

then it is followed by Debug log: refresh test, containerHolder: com.google.android.gms.tagmanager.dc@XXXXXXX

Relevant information

Add relevant project settings from *.csproj file:

Packages used:

    <PackageReference Include="Xamarin.GooglePlayServices.Analytics" Version="71.1608.1" />
    <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1610.1 />
 <PackageReference Include="Xamarin.GooglePlayServices.TagManager" Version="71.1604.1 />
 <PackageReference Include="Xamarin.Firebase.Analytics" Version="71.1630.1 />
 <PackageReference Include="Xamarin.Firebase.Messaging" Version="71.1740.1 />

Minimal Repro Code Sample

  1. Create a Xamarin Forms app.
  2. In the Android project, install the necessary nuget packages.
  3. Enable firebase and call _firebaseAnalytics.SetAnalyticsCollectionEnabled(true);.
  4. Log some events
  5. Create a GA and google tag manager account. Create a container (Android), then download the JSON file. Put the JSON file inside Assets/containers folder.
  6. Run the application while Device logcat is running (you can check error here)

Steps to Reproduce (with link to sample solution if possible):

Include any relevant Exception Stack traces, build logs, adb logs:

aian23 avatar Jun 01 '20 11:06 aian23

I was able to fix this by just downgrading all my nugets from version 71.X to 60.X

aian23 avatar Jun 02 '20 10:06 aian23

Possibly related for more digging:

https://stackoverflow.com/questions/18883511/google-tag-manager-throws-invalid-macro-message

https://stackoverflow.com/questions/18501948/android-tagmanager-not-getting-default-values/18964099#18964099

https://www.youtube.com/watch?v=Xe8W5w68BRg&feature=youtu.be&t=8m26s

https://github.com/cwilson1031/analytics-issues/issues/635

https://en.it1352.com/article/a0acd60d21a3455299dd419b4620f627.html

moljac avatar Jul 17 '20 10:07 moljac