"error: cannot find symbol variable xml" while trying google analytics
Check if you don't forget to put
apply plugin: 'com.google.gms.google-services'
in app level build.gradle
The brute force solution is to simply provide the actual analytics code.
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker tracker = analytics.newTracker("UA-XXXXXXXXX-X");
rather than following the android conventional procedure
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker tracker = analytics.newTracker(R.xml.global_tracker);
It's a pretty savage way of fixing the issue but it surely works because the newTracker() method only needs the actual string value of the Google Analytics tracking code.
The official reference document even have the same paradigm example.
You need to create a new folder in your res folder called xml
and move your file to that folder. Also make sure you call the layout name correctly because in your question, you wrote Global_tracker.xml
instead of global_tracker.xml
. This is so important.
Hope that helps.