am 2d83400e: Merge "LayoutLib: Improve error reporting." into honeycomb
* commit '2d83400e59f939a25c471d87dbdc7a50ce7f2a44': LayoutLib: Improve error reporting.
This commit is contained in:
@@ -351,7 +351,8 @@ public class BitmapFactory {
|
|||||||
If the exception happened on open, bm will be null.
|
If the exception happened on open, bm will be null.
|
||||||
If it happened on close, bm is still valid.
|
If it happened on close, bm is still valid.
|
||||||
*/
|
*/
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null,
|
||||||
|
String.format("Error decoding bitmap of id 0x%x", id), e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (is != null) is.close();
|
if (is != null) is.close();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public final class NinePatch_Delegate {
|
|||||||
oos = new ObjectOutputStream(baos);
|
oos = new ObjectOutputStream(baos);
|
||||||
oos.writeObject(chunk);
|
oos.writeObject(chunk);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bridge.getLog().error("Failed to serialize NinePatchChunk.", e);
|
Bridge.getLog().error(null, "Failed to serialize NinePatchChunk.", e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (oos != null) {
|
if (oos != null) {
|
||||||
@@ -196,10 +196,10 @@ public final class NinePatch_Delegate {
|
|||||||
sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk));
|
sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bridge.getLog().error("Failed to deserialize NinePatchChunk content.", e);
|
Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk content.", e);
|
||||||
return null;
|
return null;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Bridge.getLog().error("Failed to deserialize NinePatchChunk class.", e);
|
Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk class.", e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if (ois != null) {
|
if (ois != null) {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class XmlUtils_Delegate {
|
|||||||
// The Dalvik libraries are able to handle Integer.parse("XXXXXXXX", 16) where XXXXXXX
|
// The Dalvik libraries are able to handle Integer.parse("XXXXXXXX", 16) where XXXXXXX
|
||||||
// is > 80000000 but the Java VM cannot.
|
// is > 80000000 but the Java VM cannot.
|
||||||
|
|
||||||
int value;
|
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int len = nm.length();
|
int len = nm.length();
|
||||||
@@ -51,7 +50,7 @@ public class XmlUtils_Delegate {
|
|||||||
if (index == (len - 1))
|
if (index == (len - 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char c = nm.charAt(index + 1);
|
char c = nm.charAt(index + 1);
|
||||||
|
|
||||||
if ('x' == c || 'X' == c) {
|
if ('x' == c || 'X' == c) {
|
||||||
index += 2;
|
index += 2;
|
||||||
@@ -61,14 +60,11 @@ public class XmlUtils_Delegate {
|
|||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('#' == nm.charAt(index))
|
else if ('#' == nm.charAt(index)) {
|
||||||
{
|
|
||||||
index++;
|
index++;
|
||||||
base = 16;
|
base = 16;
|
||||||
|
|
||||||
return ((int)Long.parseLong(nm.substring(index), base)) * sign;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Integer.parseInt(nm.substring(index), base) * sign;
|
return ((int)Long.parseLong(nm.substring(index), base)) * sign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,16 +141,6 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
|
|||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String tag, Throwable t) {
|
|
||||||
String message = t.getMessage();
|
|
||||||
if (message == null) {
|
|
||||||
message = t.getClass().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.err.println(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String tag, String message, Throwable throwable) {
|
public void error(String tag, String message, Throwable throwable) {
|
||||||
System.err.println(message);
|
System.err.println(message);
|
||||||
|
|||||||
@@ -178,8 +178,10 @@ public final class BridgeInflater extends LayoutInflater {
|
|||||||
|
|
||||||
return inflate(bridgeParser, root);
|
return inflate(bridgeParser, root);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null,
|
||||||
// return null below.
|
"Failed to parse file " + f.getAbsolutePath(), e);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,14 +172,13 @@ public final class BridgeResources extends Resources {
|
|||||||
|
|
||||||
return ColorStateList.createFromXml(this,
|
return ColorStateList.createFromXml(this,
|
||||||
new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
|
new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
|
||||||
} catch (XmlPullParserException e) {
|
} catch (Exception e) {
|
||||||
Bridge.getLog().error(null, e);
|
// this is an error and not warning since the file existence is checked before
|
||||||
} catch (FileNotFoundException e) {
|
// attempting to parse it.
|
||||||
// will not happen, since we pre-check
|
Bridge.getLog().error(null, "Failed to parse file " + value, e);
|
||||||
} catch (IOException e) {
|
|
||||||
Bridge.getLog().error(null, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// try to load the color state list from an int
|
// try to load the color state list from an int
|
||||||
try {
|
try {
|
||||||
@@ -245,7 +243,8 @@ public final class BridgeResources extends Resources {
|
|||||||
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
|
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
|
||||||
}
|
}
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null,
|
||||||
|
"Failed to configure parser for " + value.getValue(), e);
|
||||||
// we'll return null below.
|
// we'll return null below.
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// this shouldn't happen since we check above.
|
// this shouldn't happen since we check above.
|
||||||
@@ -279,7 +278,8 @@ public final class BridgeResources extends Resources {
|
|||||||
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
|
return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
|
||||||
}
|
}
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null,
|
||||||
|
"Failed to configure parser for " + value.getValue(), e);
|
||||||
// we'll return null below.
|
// we'll return null below.
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// this shouldn't happen since we check above.
|
// this shouldn't happen since we check above.
|
||||||
|
|||||||
@@ -322,9 +322,9 @@ public final class BridgeTypedArray extends TypedArray {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// this is an error and not warning since the file existence is checked before
|
// this is an error and not warning since the file existence is checked before
|
||||||
// attempting to parse it.
|
// attempting to parse it.
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null, "Failed to parse file " + value, e);
|
||||||
|
|
||||||
// return null below.
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// looks like were unable to resolve the color value.
|
// looks like were unable to resolve the color value.
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ public class RenderSessionImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// log it
|
// log it
|
||||||
mParams.getLog().error("Scene inflate failed", t);
|
mParams.getLog().error(null, "Scene inflate failed", t);
|
||||||
|
|
||||||
return ERROR_INFLATION.createResult(t.getMessage(), t);
|
return ERROR_INFLATION.createResult(t.getMessage(), t);
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ public class RenderSessionImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// log it
|
// log it
|
||||||
mParams.getLog().error("Scene Render failed", t);
|
mParams.getLog().error(null, "Scene Render failed", t);
|
||||||
|
|
||||||
return ERROR_UNKNOWN.createResult(t.getMessage(), t);
|
return ERROR_UNKNOWN.createResult(t.getMessage(), t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.android.ninepatch.NinePatchChunk;
|
|||||||
|
|
||||||
import org.kxml2.io.KXmlParser;
|
import org.kxml2.io.KXmlParser;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap_Delegate;
|
import android.graphics.Bitmap_Delegate;
|
||||||
@@ -40,7 +39,6 @@ import android.graphics.drawable.NinePatchDrawable;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -162,7 +160,7 @@ public final class ResourceHelper {
|
|||||||
// URL is wrong, we'll return null below
|
// URL is wrong, we'll return null below
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// failed to read the file, we'll return null below.
|
// failed to read the file, we'll return null below.
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null, "Failed lot load " + file.getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +188,14 @@ public final class ResourceHelper {
|
|||||||
d = Drawable.createFromXml(context.getResources(),
|
d = Drawable.createFromXml(context.getResources(),
|
||||||
new BridgeXmlBlockParser(parser, context, isFramework));
|
new BridgeXmlBlockParser(parser, context, isFramework));
|
||||||
return d;
|
return d;
|
||||||
} catch (XmlPullParserException e) {
|
} catch (Exception e) {
|
||||||
Bridge.getLog().error(null, e);
|
// this is an error and not warning since the file existence is checked before
|
||||||
} catch (FileNotFoundException e) {
|
// attempting to parse it.
|
||||||
// will not happen, since we pre-check
|
Bridge.getLog().error(null, "Failed to parse file " + value, e);
|
||||||
} catch (IOException e) {
|
|
||||||
Bridge.getLog().error(null, e);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Bridge.getLog().error(null,
|
||||||
|
String.format("File %s does not exist (or is not a file)", stringValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -222,7 +221,7 @@ public final class ResourceHelper {
|
|||||||
return new BitmapDrawable(context.getResources(), bitmap);
|
return new BitmapDrawable(context.getResources(), bitmap);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// we'll return null below
|
// we'll return null below
|
||||||
Bridge.getLog().error(null, e);
|
Bridge.getLog().error(null, "Failed lot load " + bmpFile.getAbsolutePath(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// attempt to get a color from the value
|
// attempt to get a color from the value
|
||||||
|
|||||||
Reference in New Issue
Block a user