Extract the so file from the apk file in batches, and extract the so file from the apk file in batches.

Source: Internet
Author: User

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))







































Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.