{"record":{"id":"8ae54db8ad821611","repo":"Tencent/matrix","slug":"process-errorstream-bufferedreader-readlines-j-8ae54d","errorCode":null,"errorMessage":"process.errorStream.bufferedReader().readLines().joinTo(StringBuilder(), \"\\n\").toString()","messagePattern":"process\\.errorStream\\.bufferedReader\\(\\)\\.readLines\\(\\)\\.joinTo\\(StringBuilder\\(\\), \"\\\\n\"\\)\\.toString\\(\\)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTaskV2.kt","lineNumber":438,"sourceCode":"            val parametersOfIgnoredResources = StringBuilder()\n            if (configOfIgnoredResources.isNotEmpty()) {\n                for (ignore in configOfIgnoredResources) {\n                    parametersOfIgnoredResources.append(ignore)\n                    parametersOfIgnoredResources.append(',')\n                }\n                parametersOfIgnoredResources.deleteCharAt(parametersOfIgnoredResources.length - 1)\n                parameters.add(\"--ignoreResources\")\n                parameters.add(parametersOfIgnoredResources.toString())\n            }\n\n            if (findOutDuplicates) {\n                parameters.add(\"-duplicatedFile\")\n            }\n\n            val process = ProcessBuilder().command(parameters).start()\n            ApkUtil.waitForProcessOutput(process)\n            if (process.exitValue() != 0) {\n                throw GradleException(process.errorStream.bufferedReader().readLines()\n                        .joinTo(StringBuilder(), \"\\n\").toString())\n            }\n\n            val checkerOutputFile = File(pathOfBuildDir, \"apk_checker.json\")   // -_-|||\n            if (checkerOutputFile.exists()) {\n                val jsonArray = Gson().fromJson(checkerOutputFile.readText(), JsonArray::class.java)\n                for (i in 0 until jsonArray.size()) {\n                    if (jsonArray.get(i).asJsonObject.get(\"taskType\").asInt == 12) {\n                        val resList = jsonArray.get(i).asJsonObject.get(\"unused-resources\").asJsonArray\n                        for (j in 0 until resList.size()) {\n                            resultOfUnused.add(resList.get(j).asString)\n                        }\n                    }\n                    if (jsonArray.get(i).asJsonObject.get(\"taskType\").asInt == 10) {\n                        val duplicatedFiles = jsonArray.get(i).asJsonObject.get(\"files\").asJsonArray\n                        for (k in 0 until duplicatedFiles.size()) {\n                            val obj = duplicatedFiles.get(k).asJsonObject\n                            val md5 = obj.get(\"md5\")","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/task/RemoveUnusedResourcesTaskV2.kt#L420-L456","documentation":"The V2 task runs Matrix-ApkChecker as an external Java process to analyze the APK; if ApkChecker exits non-zero, the task throws a GradleException whose message is the checker process's full stderr. The actual root cause is whatever ApkChecker printed — invalid checker arguments, JVM errors, or analysis failures.","triggerScenarios":"ApkChecker process launched from `exec` finishes with `exitValue() != 0` — e.g. bad `-config` JSON for the checker, missing checker jar/classes, wrong JDK version, or the checker crashing on the APK.","commonSituations":"pathOfApkChecker pointing at a jar without a proper Main-Class manifest; ApkChecker run with an unsupported Java version; checker config file referencing resources that don't exist in the APK; out-of-memory in the checker JVM.","solutions":["Read the stderr text inside the exception — it is ApkChecker's own output; run the same ApkChecker command manually to reproduce.","Verify `pathOfApkChecker` points at a runnable Matrix-ApkChecker jar (`java -jar apkchecker.jar`) and that `java` on PATH is a compatible JDK (8+).","Fix the checker arguments/config the task generates (e.g. remove invalid mapping/resGuard file paths) so the checker exits 0.","Give the checker more memory if it dies with OOM (set JAVA_OPTS or run ApkChecker standalone with -Xmx)."],"exampleFix":"// before: missing mapping file passed to checker\nmappingFile = \"build/outputs/mapping/release/mapping.txt\" // not generated (no minify)\n\n// after: only pass mapping when minifyEnabled\nmappingFile = (minifyEnabled ? \"build/outputs/mapping/release/mapping.txt\" : null)","handlingStrategy":"try-catch","validationCode":"def exitCode = \"java -jar ${pathOfApkChecker} --help\".execute().waitFor()\nassert exitCode == 0 : 'ApkChecker jar not runnable with current JDK'","typeGuard":null,"tryCatchPattern":"try { task.execute() } catch (GradleException e) { logger.error('ApkChecker failed: ' + e.message); throw e }","preventionTips":["Run ApkChecker standalone first to validate args/config.","Ensure a compatible JDK (8+) is on PATH.","Keep checker inputs (mapping/resGuard files) in sync with the actual build outputs."],"tags":["gradle","android","apkchecker","process-failure"],"backgroundTag":"http-error-response","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"}