[英]Dex cache directory isn't writable: /data/dalvik-cache
Please edit the question if needed. 如果需要,请编辑问题。
I am Using android UiAutomator . 我正在使用android UiAutomator 。
UiAutomation run perfectly , but I want use java reflection on UiAutomator.jar (Which internally contain claasses.dex) UiAutomation运行完美,但我想在UiAutomator.jar(内部包含claasses.dex)上使用java反射
So problem is that java reflection API use some.jar file (which contain xyz.class
instead of .dex
) 所以问题是Java 反射 API使用some.jar文件(其中包含
xyz.class
而不是.dex
)
So how can access this .dex file from UiAutomationTest.jar 那么如何从UiAutomationTest.jar访问此.dex文件
I am using this tool which convert .dex
to .jar( which contain .class
files) Link : how to use DEXtoJar 我正在使用此工具将
.dex
转换为.jar(其中包含.class
文件)链接: 如何使用DEXtoJar
I need it programatically. 我以编程方式需要它。 -
--
Now i am unable to load UiAutomator.jar into memory ( for getting .dex file from jar then again convert to claasses.dex to classes.jar-) 现在我无法将UiAutomator.jar加载到内存中(用于从jar中获取.dex文件,然后再次将claasses.dex转换为classes.jar-)
so it is givng following error. 所以它是跟随错误。
Code snip I am using. 我正在使用的代码片段。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Here I am placed my UiAutomationTest.jar which produce from UiAutomation ant build tool.
String sourceDir = Environment.getExternalStorageDirectory().toString()+"/UiAutomationTest.jar"; //getApplicationInfo().sourceDir;
try {
DexFile dexFile = new DexFile(sourceDir); // Exception propagate from here.
} catch (IOException e) {
e.printStackTrace();
}
//exploreJar(); // For exploring jar from dex.
}
Logcat message: Logcat消息:
07-31 15:50:18.339: E/dalvikvm(19748): Dex cache directory isn't writable: /data/dalvik-cache
07-31 15:50:18.339: W/System.err(19748): java.io.IOException: unable to open DEX file
07-31 15:50:18.339: W/System.err(19748): at dalvik.system.DexFile.openDexFile(Native Method)
07-31 15:50:18.339: W/System.err(19748): at dalvik.system.DexFile.<init>(DexFile.java:78)
07-31 15:50:18.339: W/System.err(19748): at com.example.dextestproject.MainActivity.onCreate(MainActivity.java:35)
07-31 15:50:18.349: W/System.err(19748): at android.app.Activity.performCreate(Activity.java:5008)
07-31 15:50:18.349: W/System.err(19748): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-31 15:50:18.349: W/System.err(19748): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2026)
07-31 15:50:18.349: W/System.err(19748): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2087)
07-31 15:50:18.349: W/System.err(19748): at android.app.ActivityThread.access$600(ActivityThread.java:133)
07-31 15:50:18.349: W/System.err(19748): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1198)
07-31 15:50:18.349: W/System.err(19748): at android.os.Handler.dispatchMessage(Handler.java:99)
07-31 15:50:18.349: W/System.err(19748): at android.os.Looper.loop(Looper.java:137)
07-31 15:50:18.349: W/System.err(19748): at android.app.ActivityThread.main(ActivityThread.java:4803)
07-31 15:50:18.349: W/System.err(19748): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 15:50:18.349: W/System.err(19748): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 15:50:18.349: W/System.err(19748): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-31 15:50:18.349: W/System.err(19748): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-31 15:50:18.359: W/System.err(19748): at dalvik.system.NativeStart.main(Native Method)
as I learned from here Is there a way to get the class names in a given classes.dex file? 正如我从这里中学到的, 有没有一种方法可以在给定的classes.dex文件中获取类名?
you should use: 您应该使用:
File f = new File(Environment.getExternalStorageDirectory()+"/classes.zip");
File tmp = new File(Environment.getExternalStorageDirectory()+"/classes.odex");
DexFile dexfile = DexFile.loadDex(f.getAbsolutePath(), tmp.getAbsolutePath(), 0);
instead of: 代替:
DexFile dexfile = new DexFile(f);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.