From: Xavier Ducrohet Date: Tue, 7 Dec 2010 04:23:28 +0000 (-0800) Subject: Improved error message during export. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=231ec810829b9fe705c3f9a27d461edca0c0feee;p=android-x86%2Fsdk.git Improved error message during export. Change-Id: Idb9981348df22e73de3f3d2a72de50a392115cc4 --- diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java index 7af2b9d0a..50c3ff191 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java @@ -520,15 +520,17 @@ public class BuildHelper { // get the output and return code from the process execError = grabProcessOutput(mProject, process, results); - if (execError != 0) { - throw new ProguardResultException(execError, - results.toArray(new String[results.size()])); - } else if (mVerbose) { + if (mVerbose) { for (String resultString : results) { mOutStream.println(resultString); } } + if (execError != 0) { + throw new ProguardResultException(execError, + results.toArray(new String[results.size()])); + } + } catch (IOException e) { String msg = String.format(Messages.Proguard_Exec_Error, commandArray[0]); throw new ProguardExecException(msg, e); @@ -682,16 +684,15 @@ public class BuildHelper { // get the output and return code from the process execError = grabProcessOutput(mProject, process, results); - if (execError != 0) { - throw new AaptResultException(execError, - results.toArray(new String[results.size()])); - } else if (mVerbose) { + if (mVerbose) { for (String resultString : results) { mOutStream.println(resultString); } } - - + if (execError != 0) { + throw new AaptResultException(execError, + results.toArray(new String[results.size()])); + } } catch (IOException e) { String msg = String.format(Messages.AAPT_Exec_Error, command[0]); throw new AaptExecException(msg, e); 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 cdfe3b329..17fc1e2ee 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 @@ -20,12 +20,18 @@ import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; import com.android.ide.eclipse.adt.AndroidPrintStream; import com.android.ide.eclipse.adt.internal.build.BuildHelper; +import com.android.ide.eclipse.adt.internal.build.DexException; +import com.android.ide.eclipse.adt.internal.build.NativeLibInJarException; +import com.android.ide.eclipse.adt.internal.build.ProguardExecException; +import com.android.ide.eclipse.adt.internal.build.ProguardResultException; import com.android.ide.eclipse.adt.internal.sdk.ProjectState; import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.ide.eclipse.adt.io.IFileWrapper; import com.android.sdklib.SdkConstants; -import com.android.sdklib.xml.AndroidManifest; +import com.android.sdklib.build.ApkCreationException; +import com.android.sdklib.build.DuplicateFileException; import com.android.sdklib.internal.project.ProjectProperties; +import com.android.sdklib.xml.AndroidManifest; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -213,6 +219,38 @@ public final class ExportHelper { // success! } catch (CoreException e) { throw e; + } catch (ProguardResultException e) { + String msg = String.format("Proguard returned with error code %d. See console", + e.getErrorCode()); + AdtPlugin.printErrorToConsole(project, msg); + AdtPlugin.printErrorToConsole(project, (Object[]) e.getOutput()); + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + msg, e)); + } catch (ProguardExecException e) { + String msg = String.format("Failed to run proguard: %s", e.getMessage()); + AdtPlugin.printErrorToConsole(project, msg); + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + msg, e)); + } catch (DuplicateFileException e) { + String msg = String.format( + "Found duplicate file for APK: %1$s\nOrigin 1: %2$s\nOrigin 2: %3$s", + e.getArchivePath(), e.getFile1(), e.getFile2()); + AdtPlugin.printErrorToConsole(project, msg); + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + e.getMessage(), e)); + } catch (NativeLibInJarException e) { + String msg = e.getMessage(); + + AdtPlugin.printErrorToConsole(project, msg); + AdtPlugin.printErrorToConsole(project, (Object[]) e.getAdditionalInfo()); + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + e.getMessage(), e)); + } catch (DexException e) { + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + e.getMessage(), e)); + } catch (ApkCreationException e) { + throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, + e.getMessage(), e)); } catch (Exception e) { throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, "Failed to export application", e));