android-interop-test: Enable checkstyle; fix violations
diff --git a/android-interop-testing/build.gradle b/android-interop-testing/build.gradle
index 4d30e86..4d0bcfc 100644
--- a/android-interop-testing/build.gradle
+++ b/android-interop-testing/build.gradle
@@ -19,3 +19,34 @@
         jcenter()
     }
 }
+
+subprojects {
+    apply plugin: "checkstyle"
+
+    checkstyle {
+        configFile = file("$rootDir/../checkstyle.xml")
+        toolVersion = "6.17"
+        ignoreFailures = false
+        if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
+            ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
+        }
+        configProperties["rootDir"] = "$rootDir/../"
+    }
+
+    // Checkstyle doesn't run automatically with android
+    task checkStyleMain(type: Checkstyle) {
+        source 'src/main/java'
+        include '**/*.java'
+        classpath = files()
+    }
+
+    task checkStyleTest(type: Checkstyle) {
+        source 'src/test/java'
+        include '**/*.java'
+        classpath = files()
+    }
+
+    afterEvaluate { project ->
+        project.tasks['check'].dependsOn checkStyleMain, checkStyleTest
+    }
+}