misc/androidstudio: ensure gomobile bind completes before java compilation

When there is no prior gradle cache (i.e .gradle/ directory isn't created yet) in your Android project and a gradle build command is executed (e.g ./gradlew build), the *.so files generated by the gobind android plugin is not packaged into the apk.
Successive builds work fine though.

This issue doesn't happen when using Android plugin version 2.x, but does using version 3.x.

The gomobile bind task, libTask, is only finalizing the java compile task which allows it to run in parallel with javaCompile. That is probably too late, so instead, make libTask a dependency of the compile task to make sure the output of gomobile bind (in particular, the *so libraries) are included in the final build product.

Fixes golang/go#23766

Change-Id: I62727bfa0ffd54d8158c3a2aa3d7303867fcbabc
Reviewed-on: https://go-review.googlesource.com/94835
Reviewed-by: Elias Naur <elias.naur@gmail.com>
diff --git a/misc/androidstudio/src/main/groovy/org/golang/mobile/GobindPlugin.groovy b/misc/androidstudio/src/main/groovy/org/golang/mobile/GobindPlugin.groovy
index 6fb7d98..3f0dbe8 100644
--- a/misc/androidstudio/src/main/groovy/org/golang/mobile/GobindPlugin.groovy
+++ b/misc/androidstudio/src/main/groovy/org/golang/mobile/GobindPlugin.groovy
@@ -92,7 +92,8 @@
 		// TODO: Detect when building the existing JNI libraries is redundant.
 		libTask.outputs.upToDateWhen { false }
 		libTask.dependsOn(bindTask)
-		variant.javaCompile.finalizedBy(libTask)
+		// Ensure gomobile bind completes before depending on its output.
+		variant.javaCompile.dependsOn(libTask)
 	}
 }