Move to using Android Gradle Plugin 3.0.0-alpha4

Bug: 62578429
Test: ./gradlew buildOnServer
Change-Id: I354fb8d4edf8eacc75117f4cff13184865fe6b22
diff --git a/buildSrc/dependencies.gradle b/buildSrc/dependencies.gradle
index 5cf3ae6..60c3589 100644
--- a/buildSrc/dependencies.gradle
+++ b/buildSrc/dependencies.gradle
@@ -32,7 +32,7 @@
     libs.gradle = 'com.android.tools.build:gradle:' + androidPluginVersionOverride
 } else {
     // Keep gradle plugin version in sync with ub_supportlib-master manifest.
-    libs.gradle = 'com.android.tools.build:gradle:2.4.0-alpha6'
+    libs.gradle = 'com.android.tools.build:gradle:3.0.0-alpha4'
 }
 
 // Other dependencies
diff --git a/buildSrc/diff_and_docs.gradle b/buildSrc/diff_and_docs.gradle
index d2c739a..8cfc91b 100644
--- a/buildSrc/diff_and_docs.gradle
+++ b/buildSrc/diff_and_docs.gradle
@@ -440,15 +440,8 @@
                 fileTree(releaseVariant.aidlCompile.sourceOutputDir) +
                 fileTree(releaseVariant.outputs[0].processResources.sourceOutputDir)
     }
-    // NASTY WORKAROUND to allow building with both Android Studio Plugin 2.4.0-alpha6
-    // and 2.4.0-alpha8
-    if (releaseVariant.metaClass.respondsTo(releaseVariant, 'getCompileClasspath', Object)) {
-        task.classpath += releaseVariant.getCompileClasspath(null) +
-                files(releaseVariant.javaCompile.destinationDir)
-    } else {
-        task.classpath += files{releaseVariant.javaCompile.classpath.files} +
-                files(releaseVariant.javaCompile.destinationDir)
-    }
+    task.classpath += releaseVariant.getCompileClasspath(null) +
+            files(releaseVariant.javaCompile.destinationDir)
 }
 
 // configuration file for setting up api diffs and api docs
diff --git a/buildSrc/init.gradle b/buildSrc/init.gradle
index 50f2890..eb1c001 100644
--- a/buildSrc/init.gradle
+++ b/buildSrc/init.gradle
@@ -301,9 +301,10 @@
                 task.doLast {
                     def source = testApk ? project.android.sourceSets.androidTest
                             : project.android.sourceSets.main
-                    if (task.hasProperty("outputFile") && !source.java.sourceFiles.isEmpty()) {
+                    if (task.hasProperty("outputDirectory") && !source.java.sourceFiles.isEmpty()) {
                         copy {
-                            from(task.outputFile)
+                            from(task.outputDirectory)
+                            include '*.apk'
                             into(rootProject.ext.testApkDistOut)
                             rename { String fileName ->
                                 // multiple modules may have the same name so prefix the name with