Concise: No more than 5 Java files
Dependency: dependent on Aapt.exe only
Support: Windows only
Function: Get the package name, version number, icon file "Get stream to File system" in the APK anthology with pure Java
Principle: Compare the previous article by Decompile and then parse Androidmanifest.xml way, this way is more simple, through simulation execution aapt intercept cmd output and organize to obtain information.
The attachment is the source code, the Test/demo is the demo, the output is the compiled jar file.
Refer to open source projects:
http://code.google.com/p/cfuture09-apkutil/
This project has been expanded on this project to support the extraction of icons.
Code snippet:
Java code
Public Static voidMain (string[] args) {Try{String Apkpath= "D:\\DEFAULTAPKTEMPSAVEFOLDER\\3G Android Market \\com.jiubang.market.apk"; if(Args.length > 0) {Apkpath= Args[0]; } apkinfo Apkinfo=Newapkutil (). Getapkinfo (Apkpath); //Print the information obtainedSystem.out.println (Apkinfo); //get icon and save to specified locationiconutil.extractfilefromapk (Apkpath, Apkinfo.getapplicationicon (), "d:\\defaultapktempsavefolder\\3g Android Market \ \ Crawler\\icon.png "); } Catch(Exception e) {e.printstacktrace (); } }
Pure Java Gets the package name, version number, icon in the APK file