shwenzhang/AndResGuard · error

the old mapping file do not exit, raw path=

Error message

the old mapping file do not exit, raw path= %s

What it means

readOldMapping (invoked from the Configuration constructor when <keepmapping> is configured) converts the mapping path to a File and throws this IOException if mOldMappingFile.exists() is false. In keep-mapping mode AndResGuard reuses the resource names from a previous proguard mapping.txt, so that file must exist before processing begins.

Solutions

  1. Point <keepmapping><path value="..."/> at the actual mapping.txt (typically app/build/outputs/mapping/<variant>/mapping.txt)
  2. Ensure the proguard/R8 minify task runs and completes before the AndResGuard task in your build order
  3. Use an absolute path or a path verified against the Gradle working directory

Example fix

// before (config.xml)
<path value="mapping.txt"/>
// after (config.xml)
<path value="/builds/app/build/outputs/mapping/release/mapping.txt"/>
Defensive patterns

Strategy: validation

Validate before calling

java.io.File mapping = new java.io.File(mappingPath);
if (!mapping.exists()) {
  throw new IllegalStateException("old mapping file missing: " + mapping.getAbsolutePath() + " — run proguard/R8 first");
}

Try / catch

try {
  new Configuration(configFile, ...);
} catch (IOException e) {
  if (e.getMessage().startsWith("the old mapping file do not exit")) {
    // generate mapping.txt (minifyEnabled build) and update the keepmapping path
  }
  throw e;
}

Prevention

When it happens

Trigger: <keepmapping><path value="..."/> points to a mapping.txt that does not exist on disk — wrong path, file not yet generated by proguard/R8, or path relative to a different working directory.

Common situations: Running resourceproguard before the proguard task produced mapping.txt in CI ordering issues; mapping.txt generated per-variant but config points at a fixed location; stale config after moving the module.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/77ed0618258a3ff8. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/com/tencent/mm/resourceproguard/Configuration.java:450

              mMergeDuplicatedRes = vaule.equals("true");
              System.out.println("mMergeDuplicatedRes " + mMergeDuplicatedRes);
              break;
            case ATTR_SIGNFILE:
              mMetaName = vaule.trim();
              break;
            default:
              System.err.println("unknown tag " + tagName);
              break;
          }
        }
      }
    }
  }

  private void readOldMapping(String filePath) throws IOException {
    mOldMappingFile = new File(filePath);
    if (!mOldMappingFile.exists()) {
      throw new IOException(String.format("the old mapping file do not exit, raw path= %s\n",
          mOldMappingFile.getAbsolutePath()
      ));
    }
    processOldMappingFile();
    System.out.printf("you are using the keepmapping mode to proguard resouces: old mapping path:%s\n",
        mOldMappingFile.getAbsolutePath()
    );
  }

  private void processOldMappingFile() throws IOException {
    mOldResMapping.clear();
    mOldFileMapping.clear();

    FileReader fr;
    try {
      fr = new FileReader(mOldMappingFile);
    } catch (FileNotFoundException ex) {
      throw new IOException(String.format("Could not find old mapping file %s", mOldMappingFile.getAbsolutePath()));

View on GitHub (pinned to e4df245d82)