{"record":{"id":"4af520141fbc6c02","repo":"Tencent/matrix","slug":"tag-the-file-r-txt-can-not-be-null","errorCode":null,"errorMessage":"TAG + \"---The File 'R.txt' can not be null!\"","messagePattern":"TAG \\+ \"---The File 'R\\.txt' can not be null!\"","errorType":"exception","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnusedResourcesTask.java","lineNumber":108,"sourceCode":"        resguardMap = new HashMap<>();\n        resourceDefMap = new HashMap<>();\n        styleableMap = new HashMap<>();\n        resourceRefSet = new HashSet<>();\n        unusedResSet = new HashSet<>();\n        nonValueReferences = new HashMap<>();\n        visitPath = new Stack<String>();\n    }\n\n    @Override\n    public void init() throws TaskInitException {\n        super.init();\n\n        String inputPath = config.getUnzipPath();\n        if (Util.isNullOrNil(inputPath)) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        if (!params.containsKey(JobConstants.PARAM_R_TXT) || Util.isNullOrNil(params.get(JobConstants.PARAM_R_TXT))) {\n            throw new TaskInitException(TAG + \"---The File 'R.txt' can not be null!\");\n        }\n        resourceTxt = new File(params.get(JobConstants.PARAM_R_TXT));\n        if (!FileUtil.isLegalFile(resourceTxt)) {\n            throw new TaskInitException(TAG + \"---The Resource declarations file 'R.txt' is not legal!\");\n        }\n        inputFile = new File(inputPath);\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not exist!\");\n        } else if (!inputFile.isDirectory()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not directory!\");\n        }\n        if (!Util.isNullOrNil(config.getMappingFilePath())) {\n            mappingTxt = new File(config.getMappingFilePath());\n            if (!FileUtil.isLegalFile(mappingTxt)) {\n                throw new TaskInitException(TAG + \"---The Proguard mapping file 'mapping.txt' is not legal!\");\n            }\n        }\n        if (params.containsKey(JobConstants.PARAM_IGNORE_RESOURCES_LIST) && !Util.isNullOrNil(params.get(JobConstants.PARAM_IGNORE_RESOURCES_LIST))) {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/UnusedResourcesTask.java#L90-L126","documentation":"UnusedResourcesTask.init() throws TaskInitException when params contains no R.txt path or the value is empty. R.txt (resource declarations) is required to map resource names to IDs when detecting unused resources.","triggerScenarios":"Calling addTask for UnusedResourcesTask without JobConstants.PARAM_R_TXT, or passing an empty string for it.","commonSituations":"AGP version changes where R.txt generation is missing/disabled (e.g., buildFeatures missing or non-Application modules), or forgetting the -R parameter on the ApkChecker CLI.","solutions":["Pass the R.txt path: params.put(JobConstants.PARAM_R_TXT, path/to/R.txt) or -R <path> on the CLI","Ensure your app module generates R.txt (AGP generates it in build/intermediates for application modules)","Point to the R.txt of the application (app) module, not a library"],"exampleFix":"// before\njob.addTask(TaskFactory.TASK_TYPE_UNUSED_RESOURCES);\n// after\nMap<String, String> params = new HashMap<>();\nparams.put(JobConstants.PARAM_R_TXT, \"/project/app/build/intermediates/runtime_symbol_list/debug/R.txt\");\njob.addTask(TaskFactory.TASK_TYPE_UNUSED_RESOURCES, params);","handlingStrategy":"validation","validationCode":"String rTxt = params.get(JobConstants.PARAM_R_TXT);\nif (rTxt == null || rTxt.isEmpty()) throw new IllegalArgumentException(\"PARAM_R_TXT required\");\nif (!new File(rTxt).exists()) throw new IllegalArgumentException(\"R.txt missing: \" + rTxt);","typeGuard":null,"tryCatchPattern":"try {\n    job.addTask(TaskFactory.TASK_TYPE_UNUSED_RESOURCES, params);\n} catch (TaskInitException e) {\n    log.error(\"R.txt param missing: \" + e.getMessage());\n}","preventionTips":["Always assemble the app before running ApkChecker","Point PARAM_R_TXT at the app module's generated R.txt","Document required params per task in your plugin wrapper"],"tags":["android","apk-analysis","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}