{"record":{"id":"61b189da59fece36","repo":"shwenzhang/AndResGuard","slug":"failed-to-determine-apk-s-minimum-supported-platform-version","errorCode":null,"errorMessage":"Failed to determine APK's minimum supported platform version. Use --min-sdk-version to override","messagePattern":"Failed to determine APK's minimum supported platform version\\. Use --min-sdk-version to override","errorType":"validation","errorClass":"MinSdkVersionException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/apksigner/ApkSignerTool.java","lineNumber":283,"sourceCode":"    }\n    ApkSigner.Builder apkSignerBuilder = new ApkSigner.Builder(signerConfigs).setInputApk(inputApk)\n        .setOutputApk(tmpOutputApk)\n        .setOtherSignersSignaturesPreserved(false)\n        .setV1SigningEnabled(v1SigningEnabled)\n        .setV2SigningEnabled(v2SigningEnabled)\n        .setV3SigningEnabled(v3SigningEnabled);\n    if (minSdkVersionSpecified) {\n      apkSignerBuilder.setMinSdkVersion(minSdkVersion);\n    }\n    ApkSigner apkSigner = apkSignerBuilder.build();\n    try {\n      apkSigner.sign();\n    } catch (MinSdkVersionException e) {\n      String msg = e.getMessage();\n      if (!msg.endsWith(\".\")) {\n        msg += '.';\n      }\n      throw new MinSdkVersionException(\"Failed to determine APK's minimum supported platform version\"\n                                       + \". Use --min-sdk-version to override\", e);\n    }\n    if (!tmpOutputApk.getCanonicalPath().equals(outputApk.getCanonicalPath())) {\n      Files.move(tmpOutputApk.toPath(), outputApk.toPath(), StandardCopyOption.REPLACE_EXISTING);\n    }\n\n    if (verbose) {\n      System.out.println(\"Signed\");\n    }\n  }\n\n  private static void verify(String[] params) throws Exception {\n    if (params.length == 0) {\n      printUsage(HELP_PAGE_VERIFY);\n      return;\n    }\n\n    File inputApk = null;","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/apksigner/ApkSignerTool.java#L265-L301","documentation":"The signing engine must know the APK's minimum supported platform version (read from the manifest); when it cannot determine it, sign() throws MinSdkVersionException which the tool re-wraps with guidance to pass --min-sdk-version explicitly.","triggerScenarios":"APK whose AndroidManifest cannot be parsed for minSdkVersion (unusual or corrupted manifest, missing uses-sdk attrs the parser expects) and no --min-sdk-version flag given.","commonSituations":"Heavily processed APKs (e.g. after obfuscation/resource shrinking) with malformed binary manifest; APKs built by non-standard tools; missing explicit minSdk in the manifest.","solutions":["Pass --min-sdk-version <n> explicitly (match your build.gradle minSdkVersion)","Rebuild or repair the APK so its manifest is parseable","Verify the input is a valid APK (unzip and inspect AndroidManifest.xml)"],"exampleFix":"// before\napksigner sign --ks ks.jks app.apk\n// after\napksigner sign --ks ks.jks --min-sdk-version 21 app.apk","handlingStrategy":"try-catch","validationCode":"// Pre-check the APK's manifest is parseable, or just always pass the flag:\nList<String> cmd = new ArrayList<>(List.of(\"apksigner\",\"sign\",\"--min-sdk-version\", String.valueOf(minSdkFromBuildConfig)));","typeGuard":null,"tryCatchPattern":"try { apkSigner.sign(); }\ncatch (MinSdkVersionException e) {\n    System.err.println(\"Set --min-sdk-version explicitly (e.g. your build.gradle minSdkVersion)\");\n    // retry with explicit minSdkVersion\n}","preventionTips":["Always pass --min-sdk-version explicitly, matching build.gradle minSdkVersion","Validate the input APK manifest (aapt dump badging app.apk) before signing","Avoid signing APKs already heavily rewritten by other tools without an explicit min-sdk"],"tags":["signing","apk","manifest"],"backgroundTag":"missing-required-config","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}