Tencent/matrix · error · TaskInitException
TAG + "---APK-FILE-PATH '" + inputPath + "' is illegal!"
Error message
TAG + "---APK-FILE-PATH '" + inputPath + "' is illegal!"
What it means
Thrown from UncompressedFileTask.init() when the configured APK file path is empty, or the file exists but is not a legal/valid APK file per FileUtil.isLegalFile. The task analyzes compression of entries inside the APK itself (not an unzipped tree), so an invalid APK path fails init with TaskInitException.
Solutions
- Verify the file exists and is readable (ls -l) at the configured path before launching.
- Use an absolute path, or resolve it against the correct working directory.
- Rebuild the APK for the intended variant and update the config path.
- Confirm you point at the .apk file itself, not an output directory.
Example fix
// before
cfg.setApkPath("app/build/outputs/apk/release/app-release.apk"); // file absent
// after
File apk = new File(projectDir, "app/build/outputs/apk/release/app-release.apk");
if (!apk.isFile()) throw new IllegalStateException("Build APK first: " + apk);
cfg.setApkPath(apk.getAbsolutePath()); Defensive patterns
Strategy: validation
Validate before calling
File apk = new File(apkPath);
if (!apk.isFile() || !apk.canRead()) {
throw new IllegalStateException("APK file missing or unreadable: " + apkPath);
} Type guard
boolean isLegalApk(File f) { return f != null && f.isFile() && f.canRead() && f.getName().endsWith(".apk"); } Try / catch
try {
job.run();
} catch (TaskInitException e) {
if (e.getMessage().contains("is illegal")) {
log.error("APK path '{}' does not exist or is not a regular file; build the APK first", apkPath);
} else throw e;
} Prevention
- Generate the APK path from the build system rather than hard-coding it.
- Verify the file exists right after the build, before analysis.
- Use absolute paths or set the correct working directory.
- Rebuild when switching build variants/debug releases.
When it happens
Trigger: APK path points to a file that was never built, was cleaned, is a directory, or has a typo; running from a different working directory with a relative path.
Common situations: CI building later than check runs; relative path resolved against unexpected cwd; stale config pointing to an old build variant (e.g. app-debug.apk removed).
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- TAG + "---Can not find the tool 'nm'!"
- TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not exist!"
- ---APK-UNZIP-PATH ' ' is not exist!
- ---APK-UNZIP-PATH ' ' is not exist!
- ---Manifest file ' /AndroidManifest.xml' is not exist!
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/106b61a4937c1525.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UncompressedFileTask.java:70
private Map<String, Long> uncompressSizeMap;
private Map<String, Long> compressSizeMap;
public UncompressedFileTask(JobConfig config, Map<String, String> params) {
super(config, params);
type = TASK_TYPE_UNCOMPRESSED_FILE;
}
@Override
public void init() throws TaskInitException {
super.init();
String inputPath = config.getApkPath();
if (Util.isNullOrNil(inputPath)) {
throw new TaskInitException(TAG + "---APK-FILE-PATH can not be null!");
}
inputFile = new File(inputPath);
if (!FileUtil.isLegalFile(inputFile)) {
throw new TaskInitException(TAG + "---APK-FILE-PATH '" + inputPath + "' is illegal!");
}
filterSuffix = new HashSet<>();
if (params.containsKey(JobConstants.PARAM_SUFFIX) && !Util.isNullOrNil(params.get(JobConstants.PARAM_SUFFIX))) {
String[] suffix = params.get(JobConstants.PARAM_SUFFIX).split(",");
for (String suffixStr : suffix) {
filterSuffix.add(suffixStr.trim());
}
}
uncompressSizeMap = new HashMap<>();
compressSizeMap = new HashMap<>();
}
private String getSuffix(String name) {
int index = name.indexOf('.');
if (index >= 0 && index < name.length() - 1) {View on GitHub (pinned to 3b8293bd65)