“error: cannot find symbol variable xml” while trying google analytics

后端 未结 6 615
名媛妹妹
名媛妹妹 2020-12-16 14:51

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

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 15:38

    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.

提交回复
热议问题