Commit a046f1ca authored by Skylot's avatar Skylot

core: ignore dex loading errors (#233)

parent c25f918c
...@@ -13,6 +13,7 @@ import java.util.zip.ZipFile; ...@@ -13,6 +13,7 @@ import java.util.zip.ZipFile;
import com.android.dex.Dex; import com.android.dex.Dex;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -105,8 +106,11 @@ public class InputFile { ...@@ -105,8 +106,11 @@ public class InputFile {
|| entryName.endsWith(instantRunDexSuffix)) { || entryName.endsWith(instantRunDexSuffix)) {
switch (ext) { switch (ext) {
case ".dex": case ".dex":
index++; Dex dexBuf = makeDexBuf(entryName, inputStream);
addDexFile(entryName, new Dex(inputStream)); if (dexBuf != null) {
addDexFile(entryName, dexBuf);
index++;
}
break; break;
case ".jar": case ".jar":
...@@ -140,6 +144,16 @@ public class InputFile { ...@@ -140,6 +144,16 @@ public class InputFile {
return index > 0; 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 { private static Dex loadFromJar(File jarFile) throws DecodeException {
JavaToDex j2d = new JavaToDex(); JavaToDex j2d = new JavaToDex();
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment