Tencent/matrix · error · TaskInitException

---'<config.getApkPath()>' is not exist!

Error message

---'<config.getApkPath()>' is not exist!

What it means

UnzipTask.init() checks that the configured APK file exists on disk; if new File(config.getApkPath()).exists() returns false it throws TaskInitException naming the path. The message is templated with the actual configured path at runtime (shown here as <config.getApkPath()>).

Solutions

  1. Verify the path in the error message actually exists (ls) and fix the configured path.
  2. Run/depend on the APK assembly task (e.g. assembleRelease) before the ApkCanary check task.
  3. Use an absolute path instead of a relative one to avoid working-directory differences.

Example fix

// before
config.setApkPath("app.apk"); // file not present
// after
File apk = new File("app/build/outputs/apk/release/app-release.apk");
if (!apk.exists()) throw new IllegalStateException("Build APK first");
config.setApkPath(apk.getAbsolutePath());
Defensive patterns

Strategy: validation

Validate before calling

File apk = new File(config.getApkPath());
if (!apk.isFile()) {
    throw new IllegalArgumentException("APK does not exist: " + apk.getAbsolutePath());
}

Try / catch

try {
    task.init();
} catch (TaskInitException e) {
    if (e.getMessage().contains("is not exist")) {
        throw new GradleException("Run assembleRelease before the APK check", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: config.getApkPath() is non-empty but points to a file that does not exist at the time init() runs.

Common situations: Typo in the APK path; the APK build step ran into a different output directory; running the checker before the assemble task produced the APK; relative path resolved from a different working directory in CI.

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


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/88b1657dfd26bc52. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnzipTask.java:88

        super(config, params);
        type = TASK_TYPE_UNZIP;
        proguardClassMap = new HashMap<>();
        resguardMap = new HashMap<>();
        resDirMap = new HashMap<>();
        entryNameMap = new HashMap<>();
        entrySizeMap = new HashMap<>();
    }

    @Override
    public void init() throws TaskInitException {
        super.init();
        if (Util.isNullOrNil(config.getApkPath())) {
            throw new TaskInitException(TAG + "---APK-FILE-PATH can not be null!");
        }
        Log.i(TAG, "inputPath:%s", config.getApkPath());
        inputFile = new File(config.getApkPath());
        if (!inputFile.exists()) {
            throw new TaskInitException(TAG + "---'" + config.getApkPath() + "' is not exist!");
        }
        if (Util.isNullOrNil(config.getUnzipPath())) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH can not be null!");
        }
        Log.i(TAG, "outputPath:%s", config.getUnzipPath());
        outputFile = new File(config.getUnzipPath());

        if (!Util.isNullOrNil(config.getMappingFilePath())) {
            mappingTxt = new File(config.getMappingFilePath());
            if (!FileUtil.isLegalFile(mappingTxt)) {
                throw new TaskInitException(TAG + "---mapping file " + config.getMappingFilePath() + " is not legal!");
            }
        }

        if (!Util.isNullOrNil(config.getResMappingFilePath())) {
            resMappingTxt = new File(config.getResMappingFilePath());
            if (!FileUtil.isLegalFile(resMappingTxt)) {
                throw new TaskInitException(TAG + "---resguard mapping file " + config.getResMappingFilePath() + " is not legal!");

View on GitHub (pinned to 3b8293bd65)