@@ -32,7 +32,24 @@ private static String getIsIis(File fl) {
3232 }
3333 public void loadLib (File file ) {
3434
35- DexClassLoader dcl = new DexClassLoader (file .getAbsolutePath (),this .cDir .getAbsolutePath (),getIsIis (file ),this .context .getClassLoader ());
35+ DexClassLoader dcl ;
36+ if (getIsIis (file )) {
37+ //File nativePath = new File(file, "native
38+ File libPath = new File (file .getName ().substring (0 , file .getName ().lastIndexOf ("." )) + "/native" );
39+ if (!libPath .exists ()) {
40+ libPath .mkdirs ();
41+ } else {
42+ if (!libPath .isDirectory ()) {
43+ libPath .delete ();
44+ libPath .mkdirs ();
45+ }
46+ }
47+ copyFolderFromJar (file .getAbsolutePath (), "native" , libPath );
48+ dcl = new DexClassLoader (file .getAbsolutePath (),this .cDir .getAbsolutePath (),libPath .getAbsolutePath (),this .context .getClassLoader ());
49+ } else {
50+ dcl = new DexClassLoader (file .getAbsolutePath (),this .cDir .getAbsolutePath (),null ,this .context .getClassLoader ());
51+ }
52+
3653 String className = getMainClassFromManifest (file );
3754 if (className == null ) {
3855 Logger .get ().error ("main class tidak ditemukan di manifest.json di jar: " + file .getName ());
@@ -97,6 +114,42 @@ private static String getMainClassFromManifest(File jarFile) {
97114 }
98115 return null ;
99116 }
117+
118+ public void copyFileFromJar (String jarFilePath , String sourceFileName , File destFile ) throws IOException {
119+ try (JarFile jarFile = new JarFile (jarFilePath )) {
120+ JarEntry jarEntry = jarFile .getJarEntry (sourceFileName );
121+ try (InputStream in = jarFile .getInputStream (jarEntry );
122+ FileOutputStream out = new FileOutputStream (destFile )) {
123+ byte [] buffer = new byte [1024 ];
124+ int bytesRead ;
125+ while ((bytesRead = in .read (buffer )) != -1 ) {
126+ out .write (buffer , 0 , bytesRead );
127+ }
128+ }
129+ }
130+ }
131+
132+ public void copyFolderFromJar (String jarFilePath , String sourceFolderName , File destFolder ) throws IOException {
133+ try (JarFile jarFile = new JarFile (jarFilePath )) {
134+ Enumeration <JarEntry > entries = jarFile .entries ();
135+ while (entries .hasMoreElements ()) {
136+ JarEntry entry = entries .nextElement ();
137+ if (entry .getName ().startsWith (sourceFolderName + "/" )) {
138+ String fileName = entry .getName ().substring (sourceFolderName .length () + 1 );
139+ File destFile = new File (destFolder , fileName );
140+ destFile .getParentFile ().mkdirs ();
141+ try (InputStream in = jarFile .getInputStream (entry );
142+ FileOutputStream out = new FileOutputStream (destFile )) {
143+ byte [] buffer = new byte [1024 ];
144+ int bytesRead ;
145+ while ((bytesRead = in .read (buffer )) != -1 ) {
146+ out .write (buffer , 0 , bytesRead );
147+ }
148+ }
149+ }
150+ }
151+ }
152+ }
100153 private static Boolean getNaviteLibsFromManifest (File jarFile ) {
101154 try (JarFile jar = new JarFile (jarFile )) {
102155 JarEntry entry = jar .getJarEntry ("manifest.json" );
0 commit comments