Fixing exception for android build and refactoring build.gradle.