Skip to content Skip to sidebar Skip to footer

Cannot Resolve Method Newtracker (analytics)

I'm trying to use google analytics in my project. and the newTracker method cannot be found. Also, I have no need for the ecommerce tracker so I took it out. But now i can't close

Solution 1:

Trackert= (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID)
            : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker) : null;

Modify your code like this , if trackerID is not equal to any of enum then it should return null. Error is coming as you have not completed second ternary operator. For second problem I assume that you have imported google analytics jar into your project. If it is than it wont work. Solution in that case :

  1. remove jar from project.
  2. Open SDK manager and > in extras download and install Google Play Service and Google Repository
  3. When you are done, got to Google play service set up page at "Add Google Play Services to Your Project" select from dropdown Eclipse or Android Studio and follow the process and add Google Play service project as lib to your own project

4 . add

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> to application tag of your manifest. and it will work.

I have checked its working now.

Post a Comment for "Cannot Resolve Method Newtracker (analytics)"