From 9cb3df85d8cc4399c7fc530e6480428ac9ffc80f Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 10 May 2015 07:36:44 -0500 Subject: [PATCH] Catch attr lookup on internal attributes Internal attributes will fail the AttrDecoder. Catch the errors and simply return the undecoded value which will be correct. Fixes #913 --- .../brut/androlib/res/decoder/ResAttrDecoder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java index 863721a1..56abffd9 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java @@ -17,6 +17,7 @@ package brut.androlib.res.decoder; import brut.androlib.AndrolibException; +import brut.androlib.err.UndefinedResObject; import brut.androlib.res.data.ResPackage; import brut.androlib.res.data.ResResSpec; import brut.androlib.res.data.value.ResAttr; @@ -32,10 +33,15 @@ public class ResAttrDecoder { type, value, rawValue); String decoded = null; - if (attrResId != 0) { - ResAttr attr = (ResAttr) getCurrentPackage().getResTable() - .getResSpec(attrResId).getDefaultResource().getValue(); - decoded = attr.convertToResXmlFormat(resValue); + if (attrResId > 0) { + try { + ResAttr attr = (ResAttr) getCurrentPackage().getResTable() + .getResSpec(attrResId).getDefaultResource().getValue(); + + decoded = attr.convertToResXmlFormat(resValue); + } catch (UndefinedResObject ex) { + // ignored + } } return decoded != null ? decoded : resValue.encodeAsResXmlAttr();