问题描述
启动活动时,系统将加载classes.dex文件并开始执行指令。我需要获得对当前活动正在执行的同一应用程序的classes.dex的只读访问权限。
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.
在网上搜索了几个小时之后,我只能推断出Android安全系统不允许访问应用程序沙箱。
After searching for hours on the net, I could only infer that the Android Security system does not allow access to the application sandbox.
但是,我需要对classes.dex文件具有只读访问权限才能完成任务。
However, i need readonly access to the classes.dex file in order to accomplish my task.
可以有人对此有见识吗?
Does anyone have a insight on this?
提前感谢!
推荐答案
取决于您要执行的操作,但是您可以访问DexFile:
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.
这篇关于如何访问Android应用程序的classes.dex?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!