Tencent/tinker · error · Exception

can not parse line %s

Error message

can not parse line %s

What it means

Raised by the line parser in merge_mapping.py (line 147) while reading a mapping file. The parser tokenizes a proguard mapping line by locating the first space and the '->' arrow; a member line looks like ' int field -> a' or ' java.lang.String method(int) -> b'. If either spaceIndex or arrowIndex is -1 (line 152 region: 'if spaceIndex < 0 or arrowIndex < 0'), the line is not recognizable proguard mapping syntax and the script aborts. Practically this fires on garbage input: feeding the wrong file (usage.txt, seeds, a config), a file with different formatting, or text with no '->' at all.

Source

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

    @staticmethod
    def get_name_and_complete_name_and_new_name(line):
        """ ___ ___ -> ___
            ___:___:___ ___(___) -> ___
            ___:___:___ ___(___):___ -> ___
            ___:___:___ ___(___):___:___ -> ___
        """
        no_space_line = line.strip()
        colonIndex1 = no_space_line.find(":")
        colonIndex2 = no_space_line.find(":", colonIndex1+1) if colonIndex1 != -1 else -1
        spaceIndex = no_space_line.find(" ", colonIndex2+2)
        argumentIndex1 = no_space_line.find("(", spaceIndex+1)
        argumentIndex2 = no_space_line.find(")", argumentIndex1+1) if argumentIndex1 != -1 else -1
        colonIndex3 = no_space_line.find(":", argumentIndex2+1) if argumentIndex2 != -1 else -1
        colonIndex4 = no_space_line.find(":", colonIndex3+1) if colonIndex3 != -1 else -1
        arrowIndex = no_space_line.find("->")

        if spaceIndex < 0 or arrowIndex < 0:
            raise Exception("can not parse line %s", no_space_line)
        name = no_space_line[spaceIndex + 1: argumentIndex1 if argumentIndex1 >= 0 else arrowIndex].strip()
        new_name = no_space_line[arrowIndex + 2:].strip()
        complete_name = no_space_line[colonIndex2 + 1:arrowIndex].strip()
        return name, complete_name,  new_name

    def print_new_mapping(self):
        output_path = os.path.join(os.getcwd(), "new_mapping.txt")
        with open(output_path, "w") as fw:
            for key in self.current_class_list:
                if key in self.current_classes:
                    data = self.current_classes[key]
                    fw.write(data.raw_line)
                    for line in data.field_methods:
                        fw.write(line)


if __name__ == '__main__':
    DealWithProguardWarning().exe(sys.argv[1:])

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Confirm each input is a genuine proguard mapping: lines must contain 'original -> obfuscated' with member lines indented by a space.
  2. If you edited a mapping, restore the ' -> ' separator and the leading indentation on member lines.
  3. Re-generate the file from a clean minified build instead of using leftovers from other proguard outputs.
  4. Sanity-check before running: grep -c ' -> ' mapping.txt should be roughly the number of non-blank lines.

Example fix

# before (member line broken — no arrow, no indent)
int count b

# after
    int count -> b
Defensive patterns

Strategy: validation

Validate before calling

# pre-check the input before running the tool
import sys
for path in sys.argv[1:3]:
    bad = [l.rstrip('\n') for l in open(path) if l.strip() and not l.strip().startswith('#') and '->' not in l]
    if bad:
        sys.exit('%s is not a proguard mapping (first bad line: %r)' % (path, bad[0]))

Type guard

def looks_like_mapping_line(line):
    s = line.strip()
    return s == '' or s.startswith('#') or ' -> ' in s or ' ->' in s

Try / catch

try:
    tool.exe(args)
except Exception as e:
    if 'can not parse line' in str(e):
        sys.exit('input is not a valid proguard mapping — regenerate mapping.txt from a minified build')
    raise

Prevention

When it happens

Trigger: Passing a file that is not a proguard/R8 mapping.txt as either argument: e.g. proguard usage.txt, mapping from a non-proguard tool, a GZIP-compressed or CRLF-mangled mapping, or a hand-edited file where a member line lost its leading space/indentation or the '->' separator.

Common situations: Mixing up output files when automating the applymapping merge flow; CI artifacts renamed so usage.txt lands where mapping.txt was expected; mappings written by newer R8 versions with unusual lines; editing mapping files manually to resolve warnings and breaking syntax.

Related errors


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