skylot/jadx · error · JadxRuntimeException

Expected variable end: '{}' (missing second '}')

Error message

Expected variable end: '{}' (missing second '}')

What it means

Thrown as JadxRuntimeException by TemplateFile's character processor when the parser is in the END state (one closing '}' seen after a variable) and encounters a character that is not '}'. The template syntax requires variables to be enclosed in double braces '{{variable}}'; a single '}' after a variable name leaves the parser in an intermediate END state expecting a second '}'. Any non-'}' character in that state is malformed.

Source

Thrown at jadx-core/src/main/java/jadx/core/export/TemplateFile.java:147

							varName = varName.substring(2);
						}
						return processVar(varName, rawValue);
				}
				break;

			default:
				switch (state) {
					case VARIABLE:
						parser.curVariable.append(ch);
						parser.skip = true;
						return null;

					case START:
						parser.state = State.NONE;
						return "{" + ch;

					case END:
						throw new JadxRuntimeException("Expected variable end: '" + parser.curVariable
								+ "' (missing second '}')");
				}
				break;
		}
		parser.skip = false;
		return null;
	}

	private String processVar(String varName, boolean rawValue) {
		String str = values.get(varName);
		if (str == null) {
			throw new JadxRuntimeException("Unknown variable: '" + varName
					+ "' in template: " + templateName);
		}
		if (!rawValue) {
			Function<String, String> sanitizer = valueSanitizer;
			if (sanitizer != null) {
				return sanitizer.apply(str);

View on GitHub (pinned to e738a26571)

Solutions

  1. Inspect the template file named in the error (templateName is included in related context) and fix the brace syntax: ensure every '{{' has a matching '}}'.
  2. If using stock jadx templates, report the bug — bundled templates should be well-formed.
  3. Validate custom templates with a simple grep for unbalanced '{{' / '}}' before use.
Defensive patterns

Strategy: validation

Validate before calling

// Validate template brace balance before processing
String content = new String(getClass().getResourceAsStream(path).readAllBytes());
long openCount = content.chars().filter(c -> c == '{').count();
long closeCount = content.chars().filter(c -> c == '}').count();
if (openCount != closeCount || openCount % 2 != 0) {
    throw new IllegalStateException("Template has unbalanced braces: " + path);
}

Prevention

When it happens

Trigger: A template file contains '{{variable}x' (only one closing brace) or '{{variable}' followed by text. The parser transitions: NONE -> START (first '{') -> VARIABLE (second '{', collects chars) -> END (first '}') -> expects second '}'. If the next char is not '}', this throws.

Common situations: Malformed template files bundled with jadx (should not happen in releases). Custom templates with incorrect brace syntax. Template corruption during build or packaging. Not typically user-facing unless custom templates are used.

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/8aa25708417b10be. Report an issue: GitHub.