use of com.taobao.android.dx.command.dexer.Main in project atlas by alibaba.
the class MemberIdsSection method getTooManyMembersMessage.
private String getTooManyMembersMessage() {
Map<String, AtomicInteger> membersByPackage = new TreeMap<String, AtomicInteger>();
for (Object member : items()) {
String packageName = ((MemberIdItem) member).getDefiningClass().getPackageName();
AtomicInteger count = membersByPackage.get(packageName);
if (count == null) {
count = new AtomicInteger();
membersByPackage.put(packageName, count);
}
count.incrementAndGet();
}
Formatter formatter = new Formatter();
try {
String memberType = this instanceof MethodIdsSection ? "method" : "field";
formatter.format("Too many %s references: %d; max is %d.%n" + new Main().getTooManyIdsErrorMessage() + "%n" + "References by package:", memberType, items().size(), DexFormat.MAX_MEMBER_IDX + 1);
for (Map.Entry<String, AtomicInteger> entry : membersByPackage.entrySet()) {
formatter.format("%n%6d %s", entry.getValue().get(), entry.getKey());
}
return formatter.toString();
} finally {
formatter.close();
}
}
use of com.taobao.android.dx.command.dexer.Main in project atlas by alibaba.
the class TypeIdsSection method writeHeaderPart.
/**
* Writes the portion of the file header that refers to this instance.
*
* @param out {@code non-null;} where to write
*/
public void writeHeaderPart(AnnotatedOutput out) {
throwIfNotPrepared();
int sz = typeIds.size();
int offset = (sz == 0) ? 0 : getFileOffset();
if (sz > DexFormat.MAX_TYPE_IDX + 1) {
throw new DexIndexOverflowException("Too many type references: " + sz + "; max is " + (DexFormat.MAX_TYPE_IDX + 1) + ".\n" + new Main().getTooManyIdsErrorMessage());
}
if (out.annotates()) {
out.annotate(4, "type_ids_size: " + Hex.u4(sz));
out.annotate(4, "type_ids_off: " + Hex.u4(offset));
}
out.writeInt(sz);
out.writeInt(offset);
}
use of com.taobao.android.dx.command.dexer.Main in project atlas by alibaba.
the class DexBuilderUtils method buildDexInJvm.
/**
* 在jvm中编译dex
* @param inJar
* @param outDex
* @param commandArgs
* @return
* @throws IOException
*/
public static File buildDexInJvm(File inJar, File outDex, List<String> commandArgs) throws IOException {
File parentDir = outDex.getParentFile();
parentDir.mkdirs();
// 先用3个线程来运行
commandArgs.add("--num-threads=3");
commandArgs.add("--output=" + outDex.getAbsolutePath());
commandArgs.add(inJar.getAbsolutePath());
String[] args = new String[commandArgs.size()];
commandArgs.toArray(args);
// Main.Arguments arguments = new Main.Arguments();
// arguments.parse(args);
new Main().main(args);
return outDex;
}
use of com.taobao.android.dx.command.dexer.Main in project atlas by alibaba.
the class DexWrapperHook method run.
public static ProcessResult run(@NonNull DexProcessBuilder processBuilder, @NonNull DexOptions dexOptions, @NonNull ProcessOutputHandler outputHandler) throws IOException, ProcessException {
ProcessOutput output = outputHandler.createOutput();
int res;
try {
// DxConsole.out = outputHandler.createOutput().getStandardOutput();
// DxConsole.err = outputHandler.createOutput().getErrorOutput();
DxConsole dxConsole = new DxConsole();
Main.Arguments args = buildArguments(processBuilder, dexOptions, dxConsole);
res = new Main().run(args);
} finally {
output.close();
}
outputHandler.handleOutput(output);
return new DexProcessResult(res);
}
Aggregations