本文整理汇总了Java中org.jf.dexlib2.writer.builder.DexBuilder.makeDexBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java DexBuilder.makeDexBuilder方法的具体用法?Java DexBuilder.makeDexBuilder怎么用?Java DexBuilder.makeDexBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.dexlib2.writer.builder.DexBuilder
的用法示例。
在下文中一共展示了DexBuilder.makeDexBuilder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildCode
import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
public static Set<String> buildCode(File smaliDir, File dexFile, DexDiffInfo info) throws IOException,
RecognitionException {
Set<String> classes = new HashSet<String>();
Set<DexBackedClassDef> classDefs = new HashSet<DexBackedClassDef>();
classDefs.addAll(info.getModifiedClasses());
classDefs.addAll(info.getAddedClasses());
final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
File smaliFile;
String className;
for (DexBackedClassDef classDef : classDefs) {
ApkPatch.currentClassType = classDef.getType();
className = TypeGenUtil.newType(classDef.getType());
AfBakSmali.disassembleClass(classDef, outFileNameHandler, getBuildOption(classDefs, 19), false, false);
smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
classes.add(className.substring(1, className.length() - 1).replace('/', '.'));
SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
}
dexBuilder.writeTo(new FileDataStore(dexFile));
return classes;
}
示例2: build
import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
private void build() throws AndrolibException {
try {
DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
for (String fileName : mSmaliDir.getDirectory().getFiles(true)) {
buildFile(fileName, dexBuilder);
}
dexBuilder.writeTo(new FileDataStore( new File(mDexFile.getAbsolutePath())));
} catch (IOException | DirectoryException ex) {
throw new AndrolibException(ex);
}
}
示例3: assembleSmaliFile
import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
/**
* 将smali文件夹转换为dex文件
* @param smaliFolder
* @param outDexFile
* @return
*/
public static boolean assembleSmaliFile(File smaliFolder,File outDexFile) throws IOException, RecognitionException {
Collection<File> smaliFiles = FileUtils.listFiles(smaliFolder, new String[]{"smali"}, true);
if(null!= smaliFiles && smaliFiles.size() > 0){
DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
for(File smaliFile:smaliFiles){
SmaliMod.assembleSmaliFile(smaliFile, dexBuilder, true, true);
}
dexBuilder.writeTo(new FileDataStore(outDexFile));
return true;
}else{
return false;
}
}
示例4: DexPrinter
import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
public DexPrinter() {
dexFile = DexBuilder.makeDexBuilder(19);
//dexAnnotation = new DexAnnotation(dexFile);
}
示例5: compileSmali
import org.jf.dexlib2.writer.builder.DexBuilder; //导入方法依赖的package包/类
public static ClassDef compileSmali(String smaliText, int apiLevel, boolean experimental)
throws RecognitionException, IOException {
CommonTokenStream tokens;
LexerErrorInterface lexer;
DexBuilder dexBuilder = DexBuilder.makeDexBuilder(apiLevel);
Reader reader = new StringReader(smaliText);
lexer = new smaliFlexLexer(reader);
tokens = new CommonTokenStream((TokenSource)lexer);
smaliParser parser = new smaliParser(tokens);
parser.setVerboseErrors(true);
parser.setAllowOdex(false);
parser.setApiLevel(apiLevel, experimental);
smaliParser.smali_file_return result = parser.smali_file();
if(parser.getNumberOfSyntaxErrors() > 0 || lexer.getNumberOfSyntaxErrors() > 0) {
throw new RuntimeException("Error occured while compiling text");
}
CommonTree t = result.getTree();
CommonTreeNodeStream treeStream = new CommonTreeNodeStream(t);
treeStream.setTokenStream(tokens);
smaliTreeWalker dexGen = new smaliTreeWalker(treeStream);
dexGen.setApiLevel(apiLevel, experimental);
dexGen.setVerboseErrors(true);
dexGen.setDexBuilder(dexBuilder);
dexGen.smali_file();
if (dexGen.getNumberOfSyntaxErrors() > 0) {
throw new RuntimeException("Error occured while compiling text");
}
MemoryDataStore dataStore = new MemoryDataStore();
dexBuilder.writeTo(dataStore);
DexBackedDexFile dexFile = new DexBackedDexFile(
new Opcodes(apiLevel, experimental), dataStore.getData());
return Iterables.getFirst(dexFile.getClasses(), null);
}