diff options
author | Raphael Moll <ralf@android.com> | 2013-05-29 22:50:31 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2013-05-30 07:31:06 -0700 |
commit | 5250249fcc94086a7bd861c9ae5a01b3858a1e56 (patch) | |
tree | 36bd0f28c20a376646fe8e5aac3f05809f52a1ff /eclipse | |
parent | cd7f7686245951574700b85985e3470141a7e2ad (diff) | |
download | sdk-5250249fcc94086a7bd861c9ae5a01b3858a1e56.zip sdk-5250249fcc94086a7bd861c9ae5a01b3858a1e56.tar.gz sdk-5250249fcc94086a7bd861c9ae5a01b3858a1e56.tar.bz2 |
ADT: display SDK load warnings, missing build-tool error.
Change-Id: Ibff4720dddb23d101bdeefd101a985c56fb04f08
Diffstat (limited to 'eclipse')
2 files changed, 35 insertions, 15 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java index 06d9275..9882a0c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java @@ -339,6 +339,8 @@ public abstract class BaseBuilder extends IncrementalProjectBuilder { mBuildToolInfo = sdk.getLatestBuildTool(); if (mBuildToolInfo == null) { + AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, + "No \"Build Tools\" package available; use SDK Manager to install one."); throw new AbortBuildException(); } else { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java index 9db10ff..ca6cc57 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java @@ -100,6 +100,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; /** * Central point to load, manipulate and deal with the Android SDK. Only one SDK can be used @@ -238,11 +239,14 @@ public final class Sdk { sCurrentSdk = null; } + final AtomicBoolean hasWarning = new AtomicBoolean(); + final AtomicBoolean hasError = new AtomicBoolean(); final ArrayList<String> logMessages = new ArrayList<String>(); ILogger log = new ILogger() { @Override public void error(@Nullable Throwable throwable, @Nullable String errorFormat, Object... arg) { + hasError.set(true); if (errorFormat != null) { logMessages.add(String.format("Error: " + errorFormat, arg)); } @@ -254,6 +258,7 @@ public final class Sdk { @Override public void warning(@NonNull String warningFormat, Object... arg) { + hasWarning.set(true); logMessages.add(String.format("Warning: " + warningFormat, arg)); } @@ -270,23 +275,36 @@ public final class Sdk { // get an SdkManager object for the location SdkManager manager = SdkManager.createManager(sdkLocation, log); - if (manager != null) { - // create the AVD Manager - AvdManager avdManager = null; - try { - avdManager = AvdManager.getInstance(manager, log); - } catch (AndroidLocationException e) { - log.error(e, "Error parsing the AVDs"); + try { + if (manager == null) { + hasError.set(true); + } else { + // create the AVD Manager + AvdManager avdManager = null; + try { + avdManager = AvdManager.getInstance(manager, log); + } catch (AndroidLocationException e) { + log.error(e, "Error parsing the AVDs"); + } + sCurrentSdk = new Sdk(manager, avdManager); + return sCurrentSdk; } - sCurrentSdk = new Sdk(manager, avdManager); - return sCurrentSdk; - } else { - StringBuilder sb = new StringBuilder("Error Loading the SDK:\n"); - for (String msg : logMessages) { - sb.append('\n'); - sb.append(msg); + } finally { + if (hasError.get() || hasWarning.get()) { + StringBuilder sb = new StringBuilder( + String.format("%s when loading the SDK:\n", + hasError.get() ? "Error" : "Warning")); + for (String msg : logMessages) { + sb.append('\n'); + sb.append(msg); + } + if (hasError.get()) { + AdtPlugin.printErrorToConsole("Android SDK", sb.toString()); + AdtPlugin.displayError("Android SDK", sb.toString()); + } else { + AdtPlugin.printToConsole("Android SDK", sb.toString()); + } } - AdtPlugin.displayError("Android SDK", sb.toString()); } return null; } |