Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HelloWorld cannot run under dalvikvm

I'm trying the Hello World example from https://android.googlesource.com/platform/dalvik/+/gingerbread/docs/hello-world.html

However, my Foo program did not run; dalvikvm complained about the following:

Dalvik VM unable to locate class 'Foo' java.lang.NoClassDefFoundError: Foo at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Foo in loader dalvik.system.PathClassLoader[/mnt/sdcard/foo.jar] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) at java.lang.ClassLoader.loadClass(ClassLoader.java:573) at java.lang.ClassLoader.loadClass(ClassLoader.java:532) ... 1 more

Logcat gave more information during the dalvikvm invocation:

D/dalvikvm( 1361): creating instr width table E/dalvikvm( 1361): Can't open dex cache '/data/dalvik-cache/mnt@[email protected]@classes.dex': No such file or directory I/dalvikvm( 1361): Unable to open or create cache for /mnt/sdcard/foo.jar (/data /dalvik-cache/mnt@[email protected]@classes.dex) W/dalvikvm( 1361): threadid=1: thread exiting with uncaught exception (group=0x4 001e9a8)

Does anyone out there know what I did wrong?

like image 837
user761567 Avatar asked May 27 '11 01:05

user761567


1 Answers

The author of the article, Andy McFadden, give me a tip:

It's trying to create a .odex file in /data/dalvik-cache. You'll need to be running as root, or have an unprotected /data/dalvik-cache.

Once I rooted my device (e.g. using SuperOneClick), it worked!


Comment by @domen: You don't actually have to be root. You can set ANDROID_DATA environment variable and it will put cache there. I.e. mkdir /data/local/tmp/dalvik-cache, export ANDROID_DATA=/data/local/tmp.

like image 82
user761567 Avatar answered Oct 13 '22 13:10

user761567