Extract the so file from the apk file in batches, and extract the so file from the apk file in batches.
The Application Scenario extracts all the so files from the apk file in batches without interrupting the apk folder. In this way, you do not need to use the apktool tool to generate a large number of intermediate files. Then, you can change the suffix of apkto. Zip and decompress the files to save disk space.
Function Description extracts a series of apk files, extracts all the so files from them, and stores them according to the apk name and the folder they were previously stored. As shown in:
Code Implementation
#!/usr/bin/env python# coding=utf-8import zipfileimport ospath = "/home/chicho/test/test/"so_path="/home/chicho/test/test/so/"apklist=os.listdir(path)for APK in apklist: if APK.endswith(".zip"): portion = os.path.splitext(APK) apkname = portion[0] abs_so_path=os.path.join(so_path,apkname) #/so/apkname/ abs_zipAPK_path=os.path.join(path,APK) z = zipfile.ZipFile(abs_zipAPK_path,'r') solists=[] for filename in z.namelist(): if filename.endswith(".so"): sofileName = os.path.basename(filename) soSource = os.path.basename(os.path.dirname(filename)) ''' make a dir with the source(arm?mips) ''' storePath=os.path.join(abs_so_path,soSource) # e.g. /.../so/apkname/mips/ if not os.path.exists(storePath): os.makedirs(storePath) ''' copy the xxx.so file to the object path ''' newsofile=os.path.join(storePath,sofileName) f = open(newsofile,'w') f.write(z.read(filename))