From a046f1caec356fdd58dcc9666e9102c6e7b46032 Mon Sep 17 00:00:00 2001 From: Skylot Date: Wed, 28 Feb 2018 21:55:19 +0300 Subject: [PATCH] core: ignore dex loading errors (#233) --- .../java/jadx/core/utils/files/InputFile.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/utils/files/InputFile.java b/jadx-core/src/main/java/jadx/core/utils/files/InputFile.java index a5c8791a4..cd6623fec 100644 --- a/jadx-core/src/main/java/jadx/core/utils/files/InputFile.java +++ b/jadx-core/src/main/java/jadx/core/utils/files/InputFile.java @@ -13,6 +13,7 @@ import java.util.zip.ZipFile; import com.android.dex.Dex; import org.apache.commons.io.IOUtils; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,8 +106,11 @@ public class InputFile { || entryName.endsWith(instantRunDexSuffix)) { switch (ext) { case ".dex": - index++; - addDexFile(entryName, new Dex(inputStream)); + Dex dexBuf = makeDexBuf(entryName, inputStream); + if (dexBuf != null) { + addDexFile(entryName, dexBuf); + index++; + } break; case ".jar": @@ -140,6 +144,16 @@ public class InputFile { return index > 0; } + @Nullable + private Dex makeDexBuf(String entryName, InputStream inputStream) { + try { + return new Dex(inputStream); + } catch (Exception e) { + LOG.error("Failed to load file: {}, error: {}", entryName, e.getMessage(), e); + return null; + } + } + private static Dex loadFromJar(File jarFile) throws DecodeException { JavaToDex j2d = new JavaToDex(); try {