Search code examples
androidinstrumentationsoot

regCount error when instrumenting apk with soot


I am instrumenting an apk file using Soot. When I add the following statement before running soot.Main (without even creating my body transformer), I get a regCount error. (The same error appears in different methods for different apk files.)

    Scene.v().addBasicClass("MyScheduler");
    // PackManager.v().getPack("jtp").add(new Transform("jtp.myInstrumenter", new MyBodyTransformer()));
    soot.Main.main(args);

The error I get is:

    Transforming android.support.v4.view.ViewConfigurationCompat$FroyoViewConfigurationVersionImpl... 
    Exception in thread "main" java.lang.RuntimeException: regCount does not match the number of arguments of the method
       at org.jf.dexlib.Code.Format.Instruction35c.checkItem(Instruction35c.java:160)
       at org.jf.dexlib.Code.Format.Instruction35c.<init>(Instruction35c.java:69)
       at soot.toDex.instructions.Insn35c.getRealInsn0(Insn35c.java:96)

Thanks in advance.


Solution

  • My problem was caused by my class code I tried to add. It is really a subtle point: I use an ArrayList of "Long"s, but some of my methods was adding/removing variables of type "long". Although Java performs boxing and I had no problems executing Java code, such discrepancy is problematic in the intermediate languages.