Fix zipalign/hprof-conv issue in ADT.

These files are now in plat-tools. also make tools 23
depend on that new plat-tools and adt/tools 23 require each
other.

Change-Id: Icdcf3b9f7f0787d385a930f7ebecfcf7049eb3e0
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
index c53fdb0..f7ef41f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
@@ -378,11 +378,6 @@
         return SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER + SdkConstants.FN_ADB;
     }
 
-    /** Returns the zipalign path relative to the sdk folder */
-    public static String getOsRelativeZipAlign() {
-        return SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_ZIPALIGN;
-    }
-
     /** Returns the emulator path relative to the sdk folder */
     public static String getOsRelativeEmulator() {
         return SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_EMULATOR;
@@ -398,11 +393,6 @@
         return getOsSdkFolder() + getOsRelativeAdb();
     }
 
-    /** Returns the absolute zipalign path */
-    public static String getOsAbsoluteZipAlign() {
-        return getOsSdkFolder() + getOsRelativeZipAlign();
-    }
-
     /** Returns the absolute traceview path */
     public static String getOsAbsoluteTraceview() {
         return getOsSdkFolder() + SdkConstants.OS_SDK_TOOLS_FOLDER +
@@ -415,7 +405,7 @@
     }
 
     public static String getOsAbsoluteHprofConv() {
-        return getOsSdkFolder() + SdkConstants.OS_SDK_TOOLS_FOLDER +
+        return getOsSdkFolder() + SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER +
                 AdtConstants.FN_HPROF_CONV;
     }
 
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
index 5f5232f..19d933d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
@@ -51,7 +51,7 @@
     /**
      * The minimum version of the SDK Tools that this version of ADT requires.
      */
-    private final static FullRevision MIN_TOOLS_REV = new FullRevision(22, 6, 2, 0);
+    private final static FullRevision MIN_TOOLS_REV = new FullRevision(23, 0, 0, 0);
 
     /**
      * Pattern to get the minimum plugin version supported by the SDK. This is read from
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
index 8168590..56e0c09 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
@@ -133,15 +133,7 @@
             String dexMergerStr = projectState.getProperty(AdtConstants.DEX_OPTIONS_DISABLE_MERGER);
             Boolean dexMerger = Boolean.valueOf(dexMergerStr);
 
-            BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
-            if (buildToolInfo == null) {
-                buildToolInfo = Sdk.getCurrent().getLatestBuildTool();
-            }
-
-            if (buildToolInfo == null) {
-                throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
-                        "No Build Tools installed in the SDK."));
-            }
+            BuildToolInfo buildToolInfo = getBuildTools(projectState);
 
             BuildHelper helper = new BuildHelper(
                     projectState,
@@ -339,6 +331,20 @@
         }
     }
 
+    public static BuildToolInfo getBuildTools(ProjectState projectState)
+            throws CoreException {
+        BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
+        if (buildToolInfo == null) {
+            buildToolInfo = Sdk.getCurrent().getLatestBuildTool();
+        }
+
+        if (buildToolInfo == null) {
+            throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
+                    "No Build Tools installed in the SDK."));
+        }
+        return buildToolInfo;
+    }
+
     /**
      * Exports an unsigned release APK after prompting the user for a location.
      *
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
index 0583bfc..170da6d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
@@ -18,10 +18,14 @@
 
 import com.android.annotations.Nullable;
 import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
 import com.android.ide.eclipse.adt.internal.utils.FingerprintUtils;
 import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
 import com.android.ide.eclipse.adt.internal.project.ExportHelper;
 import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
+import com.android.sdklib.BuildToolInfo;
+import com.android.sdklib.BuildToolInfo.PathId;
 import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput;
 import com.android.sdklib.internal.build.KeystoreHelper;
 import com.android.utils.GrabProcessOutput;
@@ -290,10 +294,14 @@
 
             // check the private key/certificate again since it may have been created just above.
             if (mPrivateKey != null && mCertificate != null) {
+                // check whether we can run zipalign.
                 boolean runZipAlign = false;
-                String path = AdtPlugin.getOsAbsoluteZipAlign();
-                File zipalign = new File(path);
-                runZipAlign = zipalign.isFile();
+
+                ProjectState projectState = Sdk.getProjectState(mProject);
+                BuildToolInfo buildToolInfo = ExportHelper.getBuildTools(projectState);
+
+                String zipAlignPath = buildToolInfo.getPath(PathId.ZIP_ALIGN);
+                runZipAlign = zipAlignPath != null && new File(zipAlignPath).isFile();
 
                 File apkExportFile = mDestinationFile;
                 if (runZipAlign) {
@@ -307,7 +315,7 @@
 
                 // align if we can
                 if (runZipAlign) {
-                    String message = zipAlign(path, apkExportFile, mDestinationFile);
+                    String message = zipAlign(zipAlignPath, apkExportFile, mDestinationFile);
                     if (message != null) {
                         displayError(message);
                         return false;
diff --git a/files/plugin.prop b/files/plugin.prop
index 34d6ae1..44a6a1b 100644
--- a/files/plugin.prop
+++ b/files/plugin.prop
@@ -1,3 +1,3 @@
 # begin plugin.prop
-plugin.version=22.6.2
+plugin.version=23.0.0
 # end plugin.prop
diff --git a/files/tools_source.properties b/files/tools_source.properties
index 829fba8..f5ef48b 100644
--- a/files/tools_source.properties
+++ b/files/tools_source.properties
@@ -1,3 +1,3 @@
 Pkg.UserSrc=false
 Pkg.Revision=23.0.0
-Platform.MinPlatformToolsRev=18
+Platform.MinPlatformToolsRev=20