Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 8527ecc

Browse files
authored
Merge pull request #108 from google/is-multi-dex-api
Is multi dex api
2 parents c12cfd0 + 9babdc4 commit 8527ecc

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ClassySharkWS/src/com/google/classyshark/Shark.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.classyshark.silverghost.SilverGhostFacade;
2020

2121
import java.io.File;
22+
import java.util.LinkedList;
2223
import java.util.List;
2324

2425
import static com.google.classyshark.silverghost.SilverGhostFacade.getGeneratedClassString;
@@ -74,7 +75,16 @@ public List<String> getAllStrings() {
7475
return SilverGhostFacade.getAllStrings(archiveFile);
7576
}
7677

78+
/**
79+
*
80+
* @return
81+
*/
82+
public boolean isMultiDex() {
83+
return SilverGhostFacade.isMultiDex(archiveFile);
84+
}
85+
7786
public static void main(String[] args) {
87+
7888
File apk =
7989
new File("/Users/bfarber/Desktop/Scenarios/3 APKs/"
8090
+ "com.google.samples.apps.iosched-333.apk");
@@ -86,5 +96,6 @@ public static void main(String[] args) {
8696
System.out.println(shark.getManifest());
8797
System.out.println(shark.getAllMethods());
8898
//System.out.println(shark.getAllStrings());
99+
System.out.println(shark.isMultiDex());
89100
}
90101
}

ClassySharkWS/src/com/google/classyshark/silverghost/SilverGhostFacade.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,29 @@ public static void exportArchive(List<String> args) {
154154
System.err.println("Internal error - couldn't write file");
155155
}
156156
}
157+
158+
/** returns true if the apk is multidex
159+
*
160+
* @param archiveFile
161+
* @return
162+
*/
163+
public static boolean isMultiDex(File archiveFile) {
164+
ContentReader contentReader = new ContentReader(archiveFile);
165+
contentReader.load();
166+
167+
List<String> allClassNames = contentReader.getAllClassNames();
168+
int numDexes = 0;
169+
170+
for(String classEntry : allClassNames) {
171+
if(classEntry.endsWith(".dex")) {
172+
numDexes++;
173+
// 2 dexes or more + optimization
174+
if(numDexes == 2) {
175+
return true;
176+
}
177+
}
178+
}
179+
180+
return false;
181+
}
157182
}

0 commit comments

Comments
 (0)