Class DexRewriter

java.lang.Object
org.jf.dexlib2.rewriter.DexRewriter
All Implemented Interfaces:
Rewriters

public class DexRewriter extends Object implements Rewriters
Out-of-the box, this class does nothing except make a picture-perfect copy of a dex file. However, it provides many points where you can hook into this process and selectively modify the dex file. For example, If you want to rename all instances (including definitions and references) of the class Lorg/blah/MyBlah; to Lorg/blah/YourBlah;
 
 DexRewriter rewriter = new DexRewriter(new RewriterModule() {
     public Rewriter<String> getTypeRewriter(Rewriters rewriters) {
         return new Rewriter<String>() {
             public String rewrite(String value) {
                 if (value.equals("Lorg/blah/MyBlah;")) {
                     return "Lorg/blah/YourBlah;";
                 }
                 return value;
             }
         };
     }
 });
 DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexFile);