Snap for 8544208 from bb5c47c321214d6c864a64f84ea1673499c16393 to studio-ee-release

Change-Id: I7f5d721acbdf8bae0c0d4307c291d95107365e8f
diff --git a/src/com/google/appindexing/fetchasgoogle/FetchAsGoogleTask.java b/src/com/google/appindexing/fetchasgoogle/FetchAsGoogleTask.java
index c033dd3..bd24ce9 100644
--- a/src/com/google/appindexing/fetchasgoogle/FetchAsGoogleTask.java
+++ b/src/com/google/appindexing/fetchasgoogle/FetchAsGoogleTask.java
@@ -16,15 +16,11 @@
 package com.google.appindexing.fetchasgoogle;
 
 import static com.android.tools.idea.projectsystem.gradle.GradleProjectSystemKt.getBuiltApksForSelectedVariant;
-import static com.google.wireless.android.sdk.stats.GradleSyncStats.Trigger.TRIGGER_BUILD_BEFORE_BUILDING_APK;
 
 import com.android.annotations.VisibleForTesting;
 import com.android.tools.idea.gradle.project.build.invoker.AssembleInvocationResult;
 import com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker;
 import com.android.tools.idea.gradle.project.build.invoker.TestCompileType;
-import com.android.tools.idea.gradle.project.sync.GradleSyncInvoker;
-import com.android.tools.idea.gradle.project.sync.GradleSyncListener;
-import com.android.tools.idea.gradle.project.sync.GradleSyncState;
 import com.android.tools.idea.model.AndroidModel;
 import com.android.tools.idea.run.ApkInfo;
 import com.google.api.services.fetchasgoogle_pa.model.ApkHolder;
@@ -41,7 +37,6 @@
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.ThreeState;
 import java.io.File;
 import java.io.IOException;
 import java.util.Date;
@@ -332,28 +327,6 @@
       try {
         final AtomicReference<String> errorMsgRef = new AtomicReference<>();
 
-        // If the model needs a sync, we need to sync "synchronously" before running.
-        // See: https://code.google.com/p/android/issues/detail?id=70718
-        GradleSyncState syncState = GradleSyncState.getInstance(myProject);
-        if (syncState.isSyncNeeded() != ThreeState.NO) {
-          GradleSyncInvoker.Request request = new GradleSyncInvoker.Request(TRIGGER_BUILD_BEFORE_BUILDING_APK);
-          request.runInBackground = false;
-          GradleSyncInvoker.getInstance().requestProjectSync(myProject, request, new GradleSyncListener() {
-            @Override
-            public void syncFailed(@NotNull Project project, @NotNull String errorMessage) {
-              errorMsgRef.set(errorMessage);
-            }
-          });
-        }
-
-        String errorMsg = errorMsgRef.get();
-        if (errorMsg != null) {
-          // Sync failed. There is no point on continuing, because most likely the model is either not there, or has stale information,
-          // including the path of the APK.
-          logger.warn("Unable to launch task. Project sync failed with message: " + errorMsg);
-          return false;
-        }
-
         final GradleBuildInvoker gradleBuildInvoker = GradleBuildInvoker.getInstance(myProject);
         ListenableFuture<AssembleInvocationResult> assembleResultFuture =
           ActionsKt.invokeAndWaitIfNeeded(