pxb1988/dex2jar · error · RuntimeException

cant mix use .param and .parameter on method

Error message

cant mix use .param and .parameter on method

What it means

AntlrSmaliUtil collects parameter declarations for a method from smali, which historically supported two syntaxes: the newer .param and the older .parameter directive. During method parsing it checks both contexts and throws RuntimeException('cant mix use .param and .parameter on method') if a single method body uses both forms. Mixing them makes register-to-parameter-index mapping ambiguous, so the parser refuses.

Solutions

  1. Edit the smali so the method uses only one syntax: convert all .parameter directives to .param form (or vice versa).
  2. Regenerate the smali with a single consistent baksmali version instead of mixing outputs.
  3. Check both branches around the reported method for stray .param/.parameter lines.
  4. Catch the RuntimeException around parsing to locate the offending method and fix it.
  5. Re-assemble after cleanup to confirm no mixed directives remain.

Example fix

// before
.method public foo(I)V
    .param p1, "x"
    .parameter "y"

// after
.method public foo(II)V
    .param p1, "x"
    .param p2, "y"
Defensive patterns

Strategy: validation

Validate before calling

boolean sawParam = false, sawParameter = false;
for (String line : Files.readAllLines(smaliFile)) {
    String t = line.strip();
    if (t.startsWith(".param ")) sawParam = true;
    if (t.startsWith(".parameter")) sawParameter = true;
}
if (sawParam && sawParameter) throw new IllegalStateException("Mixed .param and .parameter in smali");

Try / catch

try {
    AntlrSmaliUtil.parse(file);
} catch (RuntimeException e) {
    if (e.getMessage().contains("cant mix use .param and .parameter")) {
        System.err.println("Normalize parameter directives in " + file + " to one syntax.");
    } else throw e;
}

Prevention

When it happens

Trigger: A smali method declares some parameters with .param (e.g. .param p0) and others with .parameter (e.g. .parameter a, .parameter b) in the same method, parsed via AntlrSmaliUtil or d2j-smali/baksmali workflows.

Common situations: Merging or hand-editing smali from two sources (new baksmali output pasted into old-style code), partial migration of a decompiled method to the newer syntax, or copy-pasted prologue lines from different methods.

Related errors


AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08). Data as JSON: /api/errors/5f8497ec0a4d245e. Report an issue: GitHub.

Appendix: source

Thrown at d2j-smali/src/main/java/com/googlecode/d2j/smali/AntlrSmaliUtil.java:705

        return totalRegisters;
    }

    private static void acceptParameter(List<SmaliParser.SParameterContext> sParameterContexts, M m, DexMethodVisitor dexMethodVisitor) {
        if (sParameterContexts == null || sParameterContexts.size() == 0 || dexMethodVisitor == null) {
            return;
        }
        boolean hasParam = false;
        boolean hasParamter = false;
        for (SmaliParser.SParameterContext ctx : sParameterContexts) {
            if (ctx.param != null) {
                hasParam = true;
            }
            if (ctx.parameter != null) {
                hasParamter = true;
            }
        }
        if (hasParam && hasParamter) {
            throw new RuntimeException("cant mix use .param and .parameter on method");
        }
        for (int i = 0; i < sParameterContexts.size(); i++) {
            SmaliParser.SParameterContext ctx = sParameterContexts.get(i);
            int index;
            if (ctx.param != null) {
                index = m.regToParamIdx(m.pareReg(ctx.r.getText()));
            } else {
                index = i;
            }
            if (ctx.name != null) {
                m.setNameByIdx(index, unescapeStr(ctx.name.getText()));
            }
            List<SmaliParser.SAnnotationContext> annotationContexts = ctx.sAnnotation();
            if (annotationContexts.size() > 0) {
                acceptAnnotations(annotationContexts, dexMethodVisitor.visitParameterAnnotation(index));
            }
        }

View on GitHub (pinned to b5bda4fb49)