Put the Java code that runs on JVM and Android into its own project - Java library. Then you can build its JAR and run unit tests against it. Add it as a dependency to your Android project. There are a few samples that will guide you in the gradle-samples-*.zip
at the bottom of http://tools.android.com/tech-docs/new-build-system page.
There are other way where you can use one of existing libraries that enable unit testing of Android code but their set up is usually non-trivial so I would recommend you to start with the approach outlined above.