Thursday, July 5, 2012

Android SDK / Eclipse Hell

Article Summary:
1) Its not that hard to uninstall and reinstall Android SDK and Eclipse, so if your environment gets messed up, try that sooner rather than later
2) The quality of the USB cable apparently can make the difference in the success of deploying an app to your phone.

I've been working on an Android application for several months.  When I first set up Eclipse and the Android SDK on my Windows computer, it was pretty much a breeze and I was up and running quickly.  The phone simulator worked well, and when I wanted to transfer the application to the phone I plugged the phone into computer via USB and ran the project in Eclipse and the app transferred with no problem.

Then for seemingly no reason, I started getting errors when trying to transfer the application to the phone.  I tried all the easy things that had worked for me before: unplugging phone and plugging back in; turning off phone and turning back on; rebooting computer.  Nothing was working.  I was getting a timeout error, like " Unable to upload file: null" and "Launch cancelled". Another recommendation I found was to increase the timeout interval.  No luck.

I decided to install the latest Android SDK.  That's when the real hell began.  Although I'd only been developing the app for a few months, I'd played with Eclipse and Android about a year earlier, so I had an old version of Eclipse (Galileo) and the Android SDK (v7).  As soon as I updated the Android SDK to v20, running the project started giving me errors saying that the Android SDK version required some newer version of an Eclipse file.  So then I had to update Eclipse, to Helion.  Then I got lots of new errors.  I was getting pretty stressed out and things get fuzzy at this point.  But the errors were about versions again.  I saw recommendations to run "Install new software.." in Eclipse and run the Android AVD Manager.  The AVD wouldn't even run!  I think those errors said something about missing files in the  "tools" or "platform_tools" folders of the SDK, and sure enough, the new version of the SDK had some different folders and files, so I copied some things from the old SDK folders to the new ones and after much pain, finally got the AVD running again and ran updates of Android and Eclipse.

*THEN* I went into the hell of this error: "This Android SDK requires Android Developer Toolkit version 20.0.0 or above.  
Current version is 18.0.0  Please update ADT to the latest version."
I ran the AVD and Eclipse "Install new Software..." for over and over, but couldn't get to upgrade the ADT to v20 because it thought that I already had the latest version.  (This could have had something to do with the sketchy file and folder moving I did, mentioned above).  Eventually I tried manually moving files out of Eclipse's plugins and features folders to try to get Eclipse to believe I needed an update.  It seemed to work at first, but never really quite worked.

Eventually I resigned myself to reinstalling both Eclipse and the Android SDK.  I wish I would've done that many many hours earlier.  I'm always intimidated by reinstalling on Windows because it can take a while and messes with the registry and just seems like it can leave your system messy and unstable.  But what I didn't realize is that Eclipse and Android SDK aren't normal Windows programs.  They don't alter the registry or copy DLLs into weird places.  Uninstalling them is as simple as renaming or deleting the existing folders.  And installing is pretty much just unzipping a downloaded folder to a location that you choose.  So once I finally decided to go that route, then run the Android AVD and Eclipse "Install New Software...", everything reinstalled nicely and I had the latest versions of Android and Eclipse. I could start developing again!

I made some changes to the app, plugged in the phone to deploy to the phone, AND I GOT THE SAME TIMEOUT ERROR AGAIN!!!!  Hours of work struggling with the environment and it made no difference.  So now I thought it has to be my phone, so I tried my wife's phone, same thing!  I was so frustrated.  Started searching the web again and found a post on stackoverflow where someone mentioned that switching USB cables fixed the problem for them.  I tried my wife's USB cable and IT WORKED!!!  The application transferred first try with the new cable.  It seems my cable went bad at some point and all that hell was for nothing.

After all that ranting, the main points of this post are:
1) Its not that hard to uninstall and reinstall Android SDK and Eclipse, so if your environment gets messed up, try that sooner rather than later
2)  The quality of the USB cable apparently can make the difference in the success of deploying an app to your phone.  Aaaargh.

Tuesday, July 3, 2012

Google Analytics: No historical data, only real-time

This one just about drove me crazy.  I had set up Google Analytics on a few other sites with no problem.  I recently set it up on a new site and got it working fine too.  We don't check the stats too often so it was a few months later that we noticed that all the historical data was gone.  The status still looked good and I compared the Analytics code in our pages with what the Analytics site said that we should be using, and they were the same.

Somewhere in those few months, Google had launched the beta of their real-time stats.  So you can look at the real-time chart updating every second, go view the web page you're tracking, and instantly see that view show up on the real-time chart.  Very cool.  What was REALLY weird is that if I did that, I could see my real-time traffic but then the next day there was still nothing in the historical stats.  At first I thought the real-time launch was affecting our historical data and maybe it just needed a few days to get the bugs ironed out.

After doing some Google searching, I saw a few people suggest that it could be there was a filter applied to our data that was filtering all data out.  I didn't think that sounded right because a) I was still seeing real-time data, and b) I was pretty sure there was no filter applied in our account.  Well... turns out it was a filter, and a) filter's don't affect what you see in the real-time graph, and b) the only reasons I thought we didn't have a filter were because I hadn't set it up and I didn't see it in the Analytics dashboard.  Turns out a co-worker had set up the filter and I just hadn't looked hard enough to find the filters section in Analytics.  So here is how to find the Filters section.

1) Log in to Analytics.  When I log in, I get a list of the sites I'm tracking.  

2) Click on the site you want to view/modify. (That may just expand a folder, then you click on the site name again under the folder).  Then I land on the "Standard Reporting" tab.

3) On the far right of the horizontal tab navigation, click "Admin"

4) This is the part that confused me.  On this Admin page, there is a row of tabs: Profiles, Tracking Code, Property Settings, Social Settings.  Be sure that Profiles is highlighted, then below that you will see a second row of tabs with "Filters"

So if, like me, you are seeing no historical data then here is where you can remove or fix your filter(s).  In our case it was an "Include" filter set up for a subfolder, so only traffic from that subfolder was included in historical results, and it had no traffic.  If you do want to view different data sets using different filters, then you need to make a new Profile for each filtered set that you want.  I think its best to have no filters in your default Profile, then create a new Profile anytime you want to add one or more filters.