From efd8349aa5b5ddfbbb588614ceed74bf59a40b8c Mon Sep 17 00:00:00 2001 From: Alsan Wong Date: Fri, 18 Jan 2013 15:31:22 +0800 Subject: [PATCH] fix for ResValue cast to ResAttr exception (not really, just bypass) --- .../res/data/value/ResStyleValue.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java index b6ce42a9..5b060a06 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResStyleValue.java @@ -50,12 +50,25 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab for (int i = 0; i < mItems.length; i++) { ResResSpec spec = mItems[i].m1.getReferent(); - // hacky-fix remove bad ReferenceVars - if (spec.getDefaultResource().getValue().toString().contains("ResReferenceValue@")) { - continue; - } - ResAttr attr = (ResAttr) spec.getDefaultResource().getValue(); - String value = attr.convertToResXmlFormat(mItems[i].m2); + // fix for ClassCastException by Alsan Wong at 2013/01/18 15:08 + ResAttr attr = null; + String value = null; + + try { + // hacky-fix remove bad ReferenceVars + ResValue attrValue = spec.getDefaultResource().getValue(); + value = attrValue.toString(); // I know, this is not good, but I don't want another variable just for exception handling + + if(true == value.contains("ResReferenceValue@")) { + continue; + } + + attr = (ResAttr)attrValue; + value = attr.convertToResXmlFormat(mItems[i].m2); + } catch(ClassCastException e) { + System.out.println("ClassCastException: " + e.getMessage()); + System.out.println(value); + } if (value == null) { value = mItems[i].m2.encodeAsResXmlValue();