@@ -75,6 +75,7 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile,
75
75
}
76
76
77
77
if (zipEntry .getName ().endsWith (".dex" )) {
78
+
78
79
File file = File .createTempFile ("classes" + dexIndex , "dex" );
79
80
file .deleteOnExit ();
80
81
@@ -89,7 +90,7 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile,
89
90
fos .close ();
90
91
91
92
List <String > classesAtDex =
92
- DexReader .readClassNamesFromDex (binaryArchiveFile );
93
+ DexReader .readClassNamesFromDex (file );
93
94
94
95
classNames .add ("classes" + dexIndex + ".dex" );
95
96
classNames .addAll (classesAtDex );
@@ -100,6 +101,58 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile,
100
101
new ContentReader .Component (zipEntry .getName (),
101
102
ContentReader .ARCHIVE_COMPONENT .NATIVE_LIBRARY ));
102
103
}
104
+
105
+ // Dynamic dex loading
106
+ if (zipEntry .getName ().endsWith ("jar" ) || zipEntry .getName ().endsWith ("zip" )) {
107
+ File innerZip = File .createTempFile ("inner_zip" , "zip" );
108
+ innerZip .deleteOnExit ();
109
+
110
+ FileOutputStream fos =
111
+ new FileOutputStream (innerZip );
112
+ byte [] bytes = new byte [1024 ];
113
+ int length ;
114
+ while ((length = zipFile .read (bytes )) >= 0 ) {
115
+ fos .write (bytes , 0 , length );
116
+ }
117
+
118
+ fos .close ();
119
+
120
+ // so far we have a zip file
121
+ ZipInputStream fromInnerZip = new ZipInputStream (new FileInputStream (
122
+ innerZip ));
123
+
124
+ ZipEntry innerZipEntry ;
125
+
126
+ while (true ) {
127
+ innerZipEntry = fromInnerZip .getNextEntry ();
128
+
129
+ if (innerZipEntry == null ) {
130
+ break ;
131
+ }
132
+
133
+ if (innerZipEntry .getName ().endsWith (".dex" )) {
134
+ File tempDexFile = File .createTempFile ("inner_zip_classes" + dexIndex , "dex" );
135
+ tempDexFile .deleteOnExit ();
136
+
137
+ FileOutputStream fos1 = new FileOutputStream (tempDexFile );
138
+ byte [] bytes1 = new byte [1024 ];
139
+
140
+ while ((length = fromInnerZip .read (bytes1 )) >= 0 ) {
141
+ fos1 .write (bytes1 , 0 , length );
142
+ }
143
+
144
+ fos1 .close ();
145
+
146
+ List <String > classesAtDex =
147
+ DexReader .readClassNamesFromDex (tempDexFile );
148
+
149
+ String name = zipEntry .getName () + "###" + innerZipEntry .getName ();
150
+
151
+ classNames .add (name );
152
+ classNames .addAll (classesAtDex );
153
+ }
154
+ }
155
+ }
103
156
}
104
157
zipFile .close ();
105
158
0 commit comments