Web Analytics

Technically Impossible

Lets look at the weak link in your statement. Anything "Technically Impossible" basically means we haven't figured out how yet.

Exploring inside of Android package (apk file)

Abstract

Using Android application, user may sometime have curiosity against basis of output, and drives to know structure of application logic and its processing.

Thank to open source, such desires are fulfilled easily, but it is not always satisfied. As an application distributed from app stores, all Android application is not always distributed as open source.

This post introduces how to explore inside Android application (apk file) to some extent.

Assumption

This post doesn't introduce how to get apk file.

Term
apk Android PaCKage
Android application PaCKage
singed zip file
dex Dalvik EXecutable format Dalvik VM byte code
jar Java ARchive signed zip file
Inside of apk*1
AndroidManifest.xml information about application version
permission
libraries
etc
classes.dex executable want to know inside this
META-INF signature
res non-compiled resources font
image
etc
resources.arsc meta information about resources

Explore application structure

Creating new project in Android Studio, and opening apk file can accomplish a this purpose. This is also the way introduced at Android developers*2.

Build > Analyze apk...

Although followings items as XML files, images, fonts, and inside of dex file are visible in this way, processing structure is not. Next step is required for more.

Explore processing structure

To see processing structure inside of application, its steps would be

Task Tool
Unzip apl file
Take dex file
Convert dex file to jar file
Unzip jar file
dex2jar*3
Check the contents of jar file JD-GUI*4
Convert class file to java file Jad*5

Both dex2jar and Jad are command-line tool. Assuming that both are stored at certain folders with appropriate path settings, and refer and output files to following paths

folder stored apk file d:\work\20221126\MyApplication.apk
output from converting apk d:\work\20221126\output\
output from converting class file d:\work\20221126\jad\

dex2jar command woul be

.\d2j-dex2jar.bat -o "d:\work\20221126\output\" "d:\work\20221126\MyApplication.apk"

Contents of apk files are automatically converted as apk→dex→jar. And jar file is automatically unzip and deployed its contents to a designated folder.

Rummage about in the folder, make an educated guess at adequate class file. Them, run JD-GUI and open this class file, structure of application is automatically output. The attached image at the top of this post is its screenshot. Needless to say, inside of class file can be seen, too.

Search related keyword (Search string) to close expected process.

Search > Search...

With checking "Search For" items in advance, return results in each key press. And check process including expected keyword when class file including expected keyword.

Aditionaly, converting class file to java file with Jad. The next command reproduces the original folder structure under the designated folder, and "MyApplication.java" is output to the corresponding folder.

.\jad -o -r -sjava -d 'D:\work\20221126\jad\' 'D:\work\20221126\output\com\ataraxianstudios\drminfo\activity\MyApplication.class'