}
private Dex loadDexBuffer() throws IOException, DecodeException {
String fileName = file.getName();
if (fileName.endsWith(".dex")) {
return new Dex(file);
}
if (fileName.endsWith(".class")) {
return loadFromClassFile(file);
}
if (fileName.endsWith(".apk")) {
Dex dex = loadFromZip(file);
if (dex == null) {
throw new IOException("File 'classes.dex' not found in file: " + file);
}
return dex;
}
if (fileName.endsWith(".jar")) {
// check if jar contains 'classes.dex'
Dex dex = loadFromZip(file);
if (dex != null) {
return dex;
}
return loadFromJar(file);
}