Committing re-worked code for upgrade to Android Studio Beta (0.8) which broke Gradle.