Disable Android Lint – Google Analytics API key problem in Eclipse

If you have encountered your Google Analytics data not being sent to the server, you know how frustrating it can be waiting until the next day and seeing no results in the dashboard. Here are a couple things I encountered in my search for this and some great solutions the problem.

The first is about encoding the GA key. Do not encode the dashes in the ga_trackingId string. Doing so will prevent you from seeing any data in your reports. This can be a big problem because the Android Lint offers this as one of their ‘improvements’ :

Replace “-” with an “en dash” character (–,&&;#8211;)?

Do not let Lint encode the dashes in your GA key! It will break Google Analytics.

The second is a precaution measure that will make sure you are not sending old or corrupt data to the GA server. If you are offline and using your app, events are added to a queue and then stored in a local database, but never fired due to lack of connection. This can cause some problems with events never firing. So to clean the local GA database file, use the following:

File analyticsDB = new File(c.getApplicationInfo().dataDir + “/databases/”, “google_analytics.db”);

if (analyticsDB.exists()) { analyticsDB.delete(); }

And last but not least, the most important piece of advice. No one dared to mention that once you clean your project, it will switch it back to the en_dash encoding. To fix this encoding problem follow these steps (Note this is specifically for Eclipse on a Mac but i’m sure the settings are located in a similar place for PC):

  1. Go into your preferences (on Mac for it’s Eclipse -> Preferences)
  2. Go to Android
  3. Go to Lint error Checking
  4. You can either disable Lint checker completely or disable just the en_dash thing (what I did)
  5. Find the one called “TypographyDashes” under Usability:Typography or search “dash” inside the search box. It should come up with TypographyDashes.
  6. Highlight it and turn it to “Ignore” under the severity
  7. From there click ‘apply’ and then allow it to re-lint.

Credit:

http://stackoverflow.com/questions/11399443/google-analytics-v2-sdk-for-android-easytracker-giving-errors

http://blog.blundell-apps.com/google-analytics-common-problems-and-fixes/