Tencent/matrix · error · TaskInitException

---APK-UNZIP-PATH can not be null!

Error message

---APK-UNZIP-PATH can not be null!

What it means

CountRTask counts R-class resources in an unzipped APK. Like CountClassTask, its init() first runs the base checks then reads config.getUnzipPath(); if the path is null or empty (Util.isNullOrNil) it throws TaskInitException with this message because the task cannot locate the extracted APK contents without it.

Solutions

  1. Set config.setUnzipPath(...) to the extracted APK directory before running the task.
  2. Ensure the unzip task in the canary job runs and stores its output path in the shared JobConfig.
  3. Check your config/gradle properties for a missing or misspelled unzip-path entry.
  4. Validate getUnzipPath() non-null/non-empty in your runner before execute().

Example fix

// before
JobConfig config = new JobConfig(); // no unzip path set
// after
JobConfig config = new JobConfig();
config.setUnzipPath(new File("build/apk-unzipped").getAbsolutePath());
Defensive patterns

Strategy: validation

Validate before calling

String unzipPath = config.getUnzipPath();
if (unzipPath == null || unzipPath.trim().isEmpty()) {
    throw new IllegalStateException("set APK-UNZIP-PATH before running CountRTask");
}

Type guard

boolean hasUnzipPath(JobConfig config) {
    String p = config == null ? null : config.getUnzipPath();
    return p != null && !p.trim().isEmpty();
}

Try / catch

try {
    countRTask.init();
} catch (TaskInitException e) {
    MatrixLog.e(TAG, "CountRTask config invalid: %s", e.getMessage());
    throw e;
}

Prevention

When it happens

Trigger: Executing CountRTask with a JobConfig whose unzip path property (APK-UNZIP-PATH) was never assigned or is set to an empty string.

Common situations: Same config-propagation gaps as CountClassTask: unzip step skipped, Gradle plugin property missing, key typo in config file, or building the JobConfig in custom tooling and forgetting setUnzipPath.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


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

Appendix: source

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

    private final List<String> dexFileNameList;
    private final List<RandomAccessFile> dexFileList;
    private final Map<String, Integer> classesMap;

    public CountRTask(JobConfig config, Map<String, String> params) {
        super(config, params);
        type = TASK_TYPE_COUNT_R_CLASS;
        dexFileNameList = new ArrayList<>();
        dexFileList = new ArrayList<>();
        classesMap = new HashMap<>();
    }

    @Override
    public void init() throws TaskInitException {
        super.init();
        String inputPath = config.getUnzipPath();

        if (Util.isNullOrNil(inputPath)) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH can not be null!");
        }

        inputFile = new File(inputPath);
        if (!inputFile.exists()) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not exist!");
        }
        if (!inputFile.isDirectory()) {
            throw new TaskInitException(TAG + "---APK-UNZIP-PATH '" + inputPath + "' is not directory!");
        }

        File[] files = inputFile.listFiles();
        try {
            if (files != null) {
                for (File file : files) {
                    if (file.isFile() && file.getName().endsWith(ApkConstants.DEX_FILE_SUFFIX)) {
                        dexFileNameList.add(file.getName());
                        RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
                        dexFileList.add(randomAccessFile);

View on GitHub (pinned to 3b8293bd65)