Tencent/tinker · error · IllegalArgumentException
file is null.
Error message
file is null.
What it means
Thrown by the Dex(File) constructor when the File argument is null. This is a plain argument-contract failure before any I/O happens: the library refuses to guess what to load. All other constructors (InputStream, byte[], ByteBuffer) bypass this check.
Source
Thrown at third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Dex.java:129
}
/**
* Creates a new dex buffer of the dex in {@code in}, and closes {@code in}.
*/
public Dex(InputStream in) throws IOException {
loadFrom(in);
}
public Dex(InputStream in, int initSize) throws IOException {
loadFrom(in, initSize);
}
/**
* Creates a new dex buffer from the dex file {@code file}.
*/
public Dex(File file) throws IOException {
if (file == null) {
throw new IllegalArgumentException("file is null.");
}
if (FileUtils.hasArchiveSuffix(file.getName())) {
ZipFile zipFile = null;
try {
zipFile = new ZipFile(file);
ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME);
if (entry != null) {
InputStream inputStream = null;
try {
inputStream = zipFile.getInputStream(entry);
loadFrom(inputStream, (int) entry.getSize());
} finally {
if (inputStream != null) {
inputStream.close();
}
}
} else {View on GitHub (pinned to 1b7ea02c23)
Solutions
- Check the upstream step that produced the File — it is null because a download, unzip, or path resolution failed; fix that first.
- Add an explicit null/exists() check before constructing Dex and fail with a descriptive message naming the expected path.
- If null is a legitimate state in your flow, branch to a different code path instead of relying on the constructor to validate.
Example fix
// before
Dex dex = new Dex(maybeNullFile);
// after
if (file == null || !file.exists()) {
throw new IllegalStateException("dex input missing: " + expectedPath);
}
Dex dex = new Dex(file); Defensive patterns
Strategy: validation
Validate before calling
if (file == null) throw new IllegalArgumentException("dex file path unresolved: " + describedSource); Prevention
- Resolve and assert file inputs at the boundary where they are produced, not deep inside parsing code.
- Log the expected path when a File lookup fails so the null is diagnosable at its origin.
When it happens
Trigger: Calling new Dex((File) null) or new Dex(file, MUTF_8?) style overloads with a null File — typically the result of a failed lookup (e.g. zip extraction returned null, a path variable never set) passed straight into the constructor.
Common situations: Patch/build scripts where the dex path comes from an environment variable, gradle task input, or a previous step that silently produced no file; refactorings that changed the variable being passed.
Related errors
- name == null
- Expected ${DEX_IN_JAR_NAME} in ${file}
- unknown output extension: ${file}
- Unexpected type: ${type}
- invalid LEB128 sequence
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/f569f14a705eab75.
Report an issue: GitHub.