Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access classes.dex of an Android Application?

When an activity is launched, the classes.dex file is loaded by the system and start executing the instructions. I need to get readonly access to the classes.dex of the same application under which the current activity is executing.

After searching for hours on the net, I could only infer that the Android Security system does not allow access to the application sandbox.

However, i need readonly access to the classes.dex file in order to accomplish my task.

Does anyone have a insight on this?

Thanks in advance!

like image 530
Pankaj Rathor Avatar asked Feb 21 '23 20:02

Pankaj Rathor


1 Answers

Depends on what you are trying to do, but you can access the DexFile :

String sourceDir = context.getApplicationInfo().sourceDir;
DexFile dexFile = new DexFile(sourceDir);

it gives you a http://developer.android.com/reference/dalvik/system/DexFile.html which you can enumerate, and load classes from.

like image 69
njzk2 Avatar answered Feb 23 '23 10:02

njzk2