diff options
author | Tor Norbye <tnorbye@google.com> | 2012-09-27 09:01:50 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-09-27 09:01:50 -0700 |
commit | bd54479ad895f373065333dbc450229664b232eb (patch) | |
tree | 9b16a722471822cabf1e8d586ae3c8f10aa24b48 | |
parent | 3c5badce945d4c2af761e1877af197beefe0443c (diff) | |
download | sdk-bd54479ad895f373065333dbc450229664b232eb.zip sdk-bd54479ad895f373065333dbc450229664b232eb.tar.gz sdk-bd54479ad895f373065333dbc450229664b232eb.tar.bz2 |
Improve aapt error message
If anything goes wrong with aapt, we emit an error message that we
could not execute aapt and to check the install location.
However, if the file exists but isn't executable, or if a parsing
error happens in the new SymbolLoader/Writer, the error message is
misleading. This changeset makes the error message more specific if it
looks like the root cause isn't a missing aapt installation.
Change-Id: Ifb09a2dd736f6a93c0f167162826e1ad6e3d2a63
4 files changed, 21 insertions, 3 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java index 7a169f3..9ceba20 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/Messages.java @@ -12,6 +12,8 @@ public class Messages extends NLS { public static String AAPT_Exec_Error_d; + public static String AAPT_Exec_Error_Other_s; + public static String Added_s_s_Needs_Updating; public static String AIDL_Exec_Error_s; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties index 70a3ab2..f387ab5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/build_messages.properties @@ -14,6 +14,7 @@ Unparsed_AAPT_Errors=Unparsed aapt error(s)\! Check the console for output. Unparsed_AIDL_Errors=Unparsed aidl error\! Check the console for output. AAPT_Exec_Error_s=Error executing aapt. Please check aapt is present at %1$s AAPT_Exec_Error_d=Error executing aapt: Return code %1$d +AAPT_Exec_Error_Other_s=Error executing aapt: %1$s Dalvik_Error_d=Conversion to Dalvik format failed with error %1$d DX_Jar_Error=Dx.jar is not found inside the plugin. Reinstall ADT\! Dalvik_Error_s=Conversion to Dalvik format failed: %1$s diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java index a55e840..2e66295 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java @@ -1127,7 +1127,18 @@ public class PreCompilerBuilder extends BaseBuilder { } catch (IOException e1) { // something happen while executing the process, // mark the project and exit - String msg = String.format(Messages.AAPT_Exec_Error_s, array.get(0)); + String msg; + String path = array.get(0); + if (!new File(path).exists()) { + msg = String.format(Messages.AAPT_Exec_Error_s, path); + } else { + String description = e1.getLocalizedMessage(); + if (e1.getCause() != null && e1.getCause() != e1) { + description = description + ": " + e1.getCause().getLocalizedMessage(); + } + msg = String.format(Messages.AAPT_Exec_Error_Other_s, description); + } + markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR); // Add workaround for the Linux problem described here: diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SymbolLoader.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SymbolLoader.java index 9c20081..3be729e 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SymbolLoader.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SymbolLoader.java @@ -65,8 +65,10 @@ public class SymbolLoader { mSymbols = HashBasedTable.create(); + String currentLine = ""; try { for (String line : lines) { + currentLine = line; // format is "<type> <class> <name> <value>" // don't want to split on space as value could contain spaces. int pos = line.indexOf(' '); @@ -79,8 +81,10 @@ public class SymbolLoader { mSymbols.put(className, name, new SymbolEntry(name, type, value)); } - } catch (ArrayIndexOutOfBoundsException e) { - throw new IOException("File format error reading " + mSymbolFile.getAbsolutePath()); + } catch (Exception e) { + // Catch both ArrayIndexOutOfBoundsException and StringIndexOutOfBoundsException + throw new IOException("File format error reading " + mSymbolFile.getAbsolutePath() + + ": " + currentLine, e); } } |