skylot/jadx · error · JadxRuntimeException

Invalid args count in insn: {}

Error message

Invalid args count in insn: {}

What it means

Thrown by ModVisitor.processArith() when an ArithNode instruction does not have exactly 2 arguments. Arithmetic operations in Dalvik (and in jadx's IR) are binary — they always have a result and two source operands (e.g. a = b + c). An ArithNode with a different arg count indicates the instruction was constructed incorrectly.

Source

Thrown at jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java:361

			String s = ((ConstStringNode) insn).getString();
			f = parentClass.getConstField(s);
		} else if (insn.getType() == InsnType.CONST_CLASS) {
			ArgType t = ((ConstClassNode) insn).getClsType();
			f = parentClass.getConstField(t);
		} else {
			f = parentClass.getConstFieldByLiteralArg((LiteralArg) insn.getArg(0));
		}
		if (f != null) {
			InsnNode inode = new IndexInsnNode(InsnType.SGET, f.getFieldInfo(), 0);
			inode.setResult(insn.getResult());
			replaceInsn(mth, block, i, inode);
			addFieldUsage(f, mth);
		}
	}

	private static void processArith(MethodNode mth, ClassNode parentClass, ArithNode arithNode) {
		if (arithNode.getArgsCount() != 2) {
			throw new JadxRuntimeException("Invalid args count in insn: " + arithNode);
		}
		InsnArg litArg = arithNode.getArg(1);
		if (litArg.isLiteral()) {
			IFieldInfoRef f = parentClass.getConstFieldByLiteralArg((LiteralArg) litArg);
			if (f != null) {
				InsnNode fGet = new IndexInsnNode(InsnType.SGET, f.getFieldInfo(), 0);
				if (arithNode.replaceArg(litArg, InsnArg.wrapArg(fGet))) {
					addFieldUsage(f, mth);
				}
			}
		}
	}

	/**
	 * Inline CMP instructions into 'if' to help conditions merging
	 */
	private static void inlineCMPInsns(MethodNode mth, BlockNode block, int i, InsnNode insn, InsnRemover remover) {
		RegisterArg resArg = insn.getResult();

View on GitHub (pinned to e738a26571)

Solutions

  1. Upgrade jadx or check for regressions if already on latest.
  2. Catch JadxRuntimeException per class and skip the offending method.
  3. Report the issue with the ArithNode toString() from the error — likely a jadx bug.
  4. Verify the DEX integrity; if corrupt, obtain a clean copy.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    javaClass.decompile();
} catch (JadxRuntimeException e) {
    LOG.warn("Invalid arith insn in {}: {}", javaClass.getName(), e.getMessage());
}

Prevention

When it happens

Trigger: processArith() receives an ArithNode from the instruction list and checks arithNode.getArgsCount() != 2. This means the ArithNode was built with 0, 1, or 3+ arguments — an invariant violation from the instruction decoder or a prior visitor that malformed the node.

Common situations: Rare; usually indicates a jadx internal bug in instruction construction or a corrupt DEX that produces a malformed arithmetic instruction. Not expected from standard compiler output. May appear after a jadx upgrade that changes ArithNode construction.

Related errors


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