Automated import from //branches/master/...@142743,142743
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java
index fa7e9b9..85ba968 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java
@@ -34,6 +34,7 @@
 import org.xml.sax.SAXParseException;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -585,19 +586,31 @@
             // get the result from the handler
             
             return new AndroidManifestParser(manifestHandler.getPackage(),
-                    manifestHandler.getActivities(), manifestHandler.getLauncherActivity(),
-                    manifestHandler.getProcesses(), manifestHandler.getDebuggable(),
-                    manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(),
+                    manifestHandler.getActivities(),
+                    manifestHandler.getLauncherActivity(),
+                    manifestHandler.getProcesses(),
+                    manifestHandler.getDebuggable(),
+                    manifestHandler.getApiLevelRequirement(),
+                    manifestHandler.getInstrumentations(),
                     manifestHandler.getUsesLibraries());
         } catch (ParserConfigurationException e) {
             AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "Bad parser configuration for %s", manifestFile.getFullPath());
+                    "Bad parser configuration for %s: %s",
+                    manifestFile.getFullPath(),
+                    e.getMessage());
         } catch (SAXException e) {
             AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "Parser exception for %s", manifestFile.getFullPath());
+                    "Parser exception for %s: %s",
+                    manifestFile.getFullPath(),
+                    e.getMessage());
         } catch (IOException e) {
-            AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "I/O error for %s", manifestFile.getFullPath());
+            // Don't log a console error when failing to read a non-existing file
+            if (!(e instanceof FileNotFoundException)) {
+                AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
+                        "I/O error for %s: %s",
+                        manifestFile.getFullPath(),
+                        e.getMessage());
+            }
         } 
 
         return null;
@@ -633,20 +646,33 @@
             // get the result from the handler
             
             return new AndroidManifestParser(manifestHandler.getPackage(),
-                    manifestHandler.getActivities(), manifestHandler.getLauncherActivity(),
-                    manifestHandler.getProcesses(), manifestHandler.getDebuggable(),
-                    manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(),
+                    manifestHandler.getActivities(),
+                    manifestHandler.getLauncherActivity(),
+                    manifestHandler.getProcesses(),
+                    manifestHandler.getDebuggable(),
+                    manifestHandler.getApiLevelRequirement(),
+                    manifestHandler.getInstrumentations(),
                     manifestHandler.getUsesLibraries());
         } catch (ParserConfigurationException e) {
             AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "Bad parser configuration for %s", manifestFile.getAbsolutePath());
+                    "Bad parser configuration for %s: %s",
+                    manifestFile.getAbsolutePath(),
+                    e.getMessage());
         } catch (SAXException e) {
             AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "Parser exception for %s", manifestFile.getAbsolutePath());
+                    "Parser exception for %s: %s",
+                    manifestFile.getAbsolutePath(),
+                    e.getMessage());
         } catch (IOException e) {
-            AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
-                    "I/O error for %s", manifestFile.getAbsolutePath());
-        } 
+            // Don't log a console error when failing to read a non-existing file
+            if (!(e instanceof FileNotFoundException)) {
+                AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), 
+                        "I/O error for %s: %s",
+                        manifestFile.getAbsolutePath(),
+                        e.getMessage());
+            }
+        }
+        
         return null;
     }
 
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/uimodel/UiElementNode.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/uimodel/UiElementNode.java
index 3728886..517284c 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/uimodel/UiElementNode.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/uimodel/UiElementNode.java
@@ -1233,8 +1233,9 @@
                 Node attr = attrs.item(n);
                 if ("xmlns".equals(attr.getPrefix())) {  //$NON-NLS-1$
                     String uri = attr.getNodeValue();
-                    String nsPrefix = attr.getLocalName(); 
-                    if (SdkConstants.NS_RESOURCES.equals(uri)) {
+                    String nsPrefix = attr.getLocalName();
+                    // Is this the URI we are looking for? If yes, we found its prefix.
+                    if (nsUri.equals(uri)) {
                         return nsPrefix;
                     }
                     visited.add(nsPrefix);
@@ -1244,7 +1245,8 @@
         
         // Use a sensible default prefix if we can't find one.
         // We need to make sure the prefix is not one that was declared in the scope
-        // visited above.
+        // visited above. Use a default namespace prefix "android" for the Android resource
+        // NS and use "ns" for all other custom namespaces.
         String prefix = SdkConstants.NS_RESOURCES.equals(nsUri) ? "android" : "ns"; //$NON-NLS-1$ //$NON-NLS-2$
         String base = prefix;
         for (int i = 1; visited.contains(prefix); i++) {
@@ -1475,18 +1477,18 @@
                 }
             }
         }
-        
+
         if (attribute != null) {
-            final UiAttributeNode fAttribute = attribute;
 
             // get the current value and compare it to the new value
-            String oldValue = fAttribute.getCurrentValue();
+            String oldValue = attribute.getCurrentValue();
             final String newValue = (String)value;
             
             if (oldValue.equals(newValue)) {
                 return;
             }
-            
+
+            final UiAttributeNode fAttribute = attribute;
             AndroidEditor editor = getEditor();
             editor.editXmlModel(new Runnable() {
                 public void run() {
@@ -1495,6 +1497,4 @@
             });
         }
     }
-
-
 }