Tencent/tinker · error · Exception

mapping file is not exist, path=%s

Error message

mapping file is not exist, path=%s

What it means

Raised by DealWithProguardWarning.exe() in tinker-build/tinker-patch-cli/tool_output/merge_mapping.py (line 84) when args[0] — the old (previous release) proguard mapping.txt — does not exist on disk. This script merges last version's mapping with the current build's mapping to produce new_mapping.txt in the CWD (the applymapping conflict workflow described in the module docstring). Note the Python-2 style bug: raise Exception("...path=%s", old_mapping_path) passes the path as a second Exception arg instead of formatting it, so the printed message shows the literal '%s'.

Source

Thrown at tinker-build/tinker-patch-cli/tool_output/merge_mapping.py:84

                    # 方法的处理,直接加进去
                    current_mapping_data.field_methods.append(line)
            classes[current_mapping_data.key] = current_mapping_data
            class_list.append(current_mapping_data.key)
        print "size: ", len(classes)

    def remove_warning_mapping(self, old_mapping, current_mapping):
        self.read_mapping_file(self.classes, self.class_list, old_mapping)
        self.read_mapping_file(self.current_classes, self.current_class_list, current_mapping)
        self.do_merge()
        self.print_new_mapping()

    def exe(self, args):
        if len(args) < 2:
            print_usage()

        old_mapping_path = args[0]
        if not os.path.exists(old_mapping_path):
            raise Exception("mapping file is not exist, path=%s", old_mapping_path)

        current_mapping_path = args[1]
        if not os.path.exists(current_mapping_path):
            raise Exception("proguard warning file is not exist, path=%s", current_mapping_path)

        self.remove_warning_mapping(old_mapping_path, current_mapping_path)

    def do_merge(self):
        # 遍历当前的mapping class_key
        for key in self.current_class_list:
            if key in self.classes:
                data = self.classes[key]
                current_data = self.current_classes[key]
                # 如果当前的类没有被混淆,则保留,否则用之前的mapping里面的内容覆盖
                # ___.___ -> ___.___:
                if current_data.raw_line.split("->")[0] != current_data.raw_line.split("->")[1][:-1]:
                    current_data.raw_line = data.raw_line
                new_method_list = []

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Verify the exact path before running: ls -l <old_mapping> from the same directory you invoke the script from.
  2. Point args[0] at the baseline build's build/outputs/mapping/release/mapping.txt (copy it somewhere durable after each release).
  3. Use absolute paths in your wrapper script to avoid CWD-relative mismatch.
  4. If you maintain the tool, format the message properly: raise Exception("mapping file is not exist, path=%s" % old_mapping_path).

Example fix

# before
python merge_mapping.py mapping_old.txt current_mapping.txt   # mapping_old.txt absent

# after
python merge_mapping.py /abs/path/to/base-apk-mapping.txt ./current_mapping.txt
Defensive patterns

Strategy: validation

Validate before calling

# shell wrapper before invoking merge_mapping.py
OLD_MAP="$1"; [ -f "$OLD_MAP" ] || { echo "old mapping missing: $OLD_MAP"; exit 1; }
python merge_mapping.py "$OLD_MAP" "$CUR_MAP"

Type guard

def is_proguard_mapping(path):
    import os
    return os.path.isfile(path)

Try / catch

try:
    merge.exe(sys.argv[1:])
except Exception as e:
    if 'mapping file is not exist' in str(e):
        sys.exit('baseline mapping not found — archive mapping.txt after every release')
    raise

Prevention

When it happens

Trigger: Running 'python merge_mapping.py old_mapping.txt current_mapping.txt' where old_mapping.txt does not exist: wrong relative path (script resolves nothing — the path is used verbatim by os.path.exists), the file is still named differently (mapping.txt from another build dir), or the previous release's mapping was never copied/saved.

Common situations: Automating patch builds where the baseline mapping lives in a CI artifact directory passed with a typo or wrong working directory; the old mapping is in the APK's build/outputs/mapping/release directory that was cleaned; first-time use of the tool without a previous mapping.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/2c2e593184bbc523. Report an issue: GitHub.