From 5eabf19157cc07a5d78369d95b0baabcb673e151 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Wed, 18 Jun 2014 00:32:58 +0200 Subject: [PATCH] Allow using the library externally by catching the exceptions while loading properties from unavailable classes. --- .../java/brut/androlib/ApktoolProperties.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java index aa1f0d76..22b8d97f 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApktoolProperties.java @@ -49,7 +49,12 @@ public class ApktoolProperties { LOGGER.warning("Can't load properties."); } - InputStream templateStream = baksmali.class.getClassLoader().getResourceAsStream("baksmali.properties"); + InputStream templateStream = null; + try { + templateStream = baksmali.class.getClassLoader().getResourceAsStream("baksmali.properties"); + } catch(NoClassDefFoundError ex) { + LOGGER.warning("Can't load baksmali properties."); + } Properties properties = new Properties(); String version = "(unknown)"; @@ -62,7 +67,12 @@ public class ApktoolProperties { } sProps.put("baksmaliVersion", version); - templateStream = main.class.getClassLoader().getResourceAsStream("smali.properties"); + templateStream = null; + try { + templateStream = main.class.getClassLoader().getResourceAsStream("smali.properties"); + } catch(NoClassDefFoundError ex) { + LOGGER.warning("Can't load smali properties."); + } properties = new Properties(); version = "(unknown)"; @@ -80,4 +90,4 @@ public class ApktoolProperties { private static final Logger LOGGER = Logger .getLogger(ApktoolProperties.class.getName()); -} \ No newline at end of file +}