Skip to content

Commit

Permalink
1.1.2-b1 fix debug mode multiclasses error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mosect committed May 23, 2022
1 parent 83445a5 commit f053349
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ afterEvaluate {
from components.java
groupId = 'com.mosect'
artifactId = 'smali-plugin'
version = '1.1.1-b12'
version = '1.1.2-b1'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,40 @@ class SmaliPlugin implements Plugin<Project> {
task.doLast {
// find dex files
List<File> dexFiles = []
def dexFileInfoList = []
outputs.files.each {
project.fileTree(it).each {
if (it.name ==~ '^classes([0-9]{1,2})?\\.dex$') {
dexFiles.add(it)
def str = it.name.substring(7, it.name.length() - 4)
int index = 1
if (str.length() > 0) {
index = Integer.parseInt(str)
}
dexFileInfoList.add([
index: index,
file : it
])
}
}
}
dexFileInfoList.sort(new Comparator() {
@Override
int compare(Object o1, Object o2) {
return o1.index - o2.index
}
})

dexFileInfoList.each {
dexFiles.add(it.file)
}

if (dexFiles.isEmpty()) {
System.err.println("DexHandler:skip dex file not found")
return
}

project.delete(tempDir)
tempDir.mkdirs()
// exists dex file
DexHandler dexHandler = new DexHandler()
dexHandler.tempDir = tempDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public File run() throws IOException, SmaliException {
List<DexMaker> dexMakerList = new ArrayList<>();
for (Map.Entry<Integer, HashSet<File>> entry : originalSourceDirMap.entrySet()) {
int dexIndex = entry.getKey();
String name = dexIndex == 1 ? "classes" : "classes" + dexIndex;
DexMaker dexMaker = new DexMaker(dexIndex);
ClassesSource classesSource = new ClassesSource();
for (File dir : entry.getValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,7 @@ private Map<String, File> loadSmaliFiles(ClassesSource source) throws IOExceptio
for (ClassesSource.SmaliFileInfo fileInfo : list) {
File old = map.put(fileInfo.getClassName(), fileInfo.getFile());
if (null != old) {
throw new IOException(String.format(
"MultipleClass[%s]: %s, %s",
fileInfo.getClassName(),
fileInfo.getFile().getAbsolutePath(),
old.getAbsolutePath()
));
System.err.printf("ReplaceClasses: %s >>> %s%n", fileInfo.getFile(), old);
}
}
return map;
Expand Down

0 comments on commit f053349

Please sign in to comment.