I am trying to implement google analytics for one of my android apps. I am totally new for analytics and android app development. I thought of trying the examples given in t
I also faced the same issue with play service library version 10.2.1 for gcm and google analytics and issue is simply fixed by adding global_tracker.xml as discussed in the @Hussein El Feky Answer but only that fix is not solved my issue also i've added two more lines in strings.xml:
<string name="global_tracker">UA-XXXXXXXX-XX</string>
<string name="gcm_defaultSenderId">PROJECT-NO</string>
I was facing the similar issue.
Use classpath com.android.tools.build:gradle:1.2.3
. That solved my problem.
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.
Check if you don't forget to put
apply plugin: 'com.google.gms.google-services'
in app level build.gradle
I had the similar issue when was preforming downgrade to lower version from
com.google.gms:google-services:3.0.0
to
com.google.gms:google-services:1.3.1
(Do not ask why(it was an assumption in order to fix CI build script in a hurry))
So, make sure that you did not made downgrade changes
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.