#!/usr/bin/env python3 """Checks the dex inside an APK the way Dalvik's dexopt does at install time: format version, size, Adler-32, SHA-1, no post-035 sections. usage: check_dex.py app.apk""" import hashlib import struct import sys import zipfile import zlib d = zipfile.ZipFile(sys.argv[1]).read("classes.dex") problems = [] if d[:8] != b"dex\n035\x00": problems.append("dex version %r (Android 2.3 needs 035)" % d[:8]) if struct.unpack("