{"record":{"id":"59260229f5cdf110","repo":"iBotPeaches/Apktool","slug":"could-not-identify-platform-osdetection-retur","errorCode":null,"errorMessage":"Could not identify platform: \" + OSDetection.returnOS()","messagePattern":"Could not identify platform: \" \\+ OSDetection\\.returnOS\\(\\)","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java","lineNumber":52,"sourceCode":"        return \"aapt2\";\n    }\n\n    public static File getBinaryFile() throws AndrolibException {\n        String binName = getBinaryName();\n\n        if (!OSDetection.is64Bit()) {\n            throw new AndrolibException(binName + \" binaries are not available for 32-bit platforms.\");\n        }\n\n        StringBuilder binPath = new StringBuilder(\"/prebuilt/\");\n        if (OSDetection.isUnix()) {\n            binPath.append(\"linux\"); // ELF 64-bit LSB executable, x86-64\n        } else if (OSDetection.isMacOSX()) {\n            binPath.append(\"macosx\"); // fat binary x86_64 + arm64\n        } else if (OSDetection.isWindows()) {\n            binPath.append(\"windows\"); // x86_64\n        } else {\n            throw new AndrolibException(\"Could not identify platform: \" + OSDetection.returnOS());\n        }\n        binPath.append('/');\n        binPath.append(binName);\n        if (OSDetection.isWindows()) {\n            binPath.append(\".exe\");\n        }\n\n        File binFile;\n        try {\n            binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString(), binName + \"_\");\n        } catch (BrutException ex) {\n            throw new AndrolibException(ex);\n        }\n        setBinaryExecutable(binFile);\n        return binFile;\n    }\n\n    private static void setBinaryExecutable(File binFile) throws AndrolibException {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java#L34-L70","documentation":"AndrolibException thrown by AaptManager.getBinaryFile() when OSDetection cannot classify the host into linux/macosx/windows (checked in that order). The bundled aapt2 lookup table only covers those three platforms, so anything else (e.g. FreeBSD, Solaris, aix, or an unrecognized os.name/os.arch combination) aborts before any resource path is built.","triggerScenarios":"Running `apktool b` on an OS whose os.name is not Linux, Mac OS X, or Windows — e.g. FreeBSD, OpenBSD, Solaris; or a JVM returning an unexpected os.name string.","commonSituations":"Building APKs inside BSD or Solaris zones/containers; exotic JVMs that normalize os.name differently; running under emulation layers that report an unusual platform.","solutions":["Run the build inside a Linux container or VM (e.g. docker run ... apktool b).","Cross-build on a supported platform and copy artifacts back.","For pure-java decode tasks, note that only build (`b`) needs the native aapt2."],"exampleFix":"# before\n$ apktool b app   # on FreeBSD host\n# after\n$ docker run --rm -v \"$PWD\":/w -w /w ibotpeaches/apktool:latest b app","handlingStrategy":"fallback","validationCode":"String os = OSDetection.returnOS();\nif (!(OSDetection.isUnix() || OSDetection.isMacOSX() || OSDetection.isWindows())) {\n    // run build in a Linux container instead\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run apktool builds inside a Linux docker image for platform independence.","Document supported host platforms (linux/macos/windows x64) in tooling docs."],"tags":["apktool","aapt2","platform","build","environment"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}