This code is deprecated because of the new API - see new repo: Android testing.
Test using Android UiAutomator library.
You must include JUnit, uiautomator.jar and android.jar libraries into the project.
How to build the JAR for the test and run it on the device is written on the developer.android.com website.