HelloWorld cannot work under dalvikvm

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

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

Dalvik VM cannot find the class 'Foo' java.lang.NoClassDefFoundError: Foo in dalvik.system.NativeStart.main (native method) Raised: java.lang.ClassNotFoundException: Foo in the bootloader dalvik.system.PathClassLoader [/ mnt / sdcard foo.jar] in dalvik.system.PathClassLoader.findClass (PathClassLoader.java:243) in java.lang.ClassLoader.loadClass (ClassLoader.java∗73) in java.lang.ClassLoader.loadClass (ClassLoader.javahaps32). .. 1 more

Logcat gave more information during the dalvikvm call:

D / dalvikvm (1361): creating instr width table E / dalvikvm (1361): cannot open cache cache '/ data / dalvik-cache / mnt@sdcard @ foo.jar@classes.dex ': there is no such file or directory I / dalvikvm (1361): cannot open or create a cache for /mnt/sdcard/foo.jar(/data / dalvik -cache / mnt@sdcard @ foo.jar@classes.dex ) W / dalvikvm (1361): threadid = 1: thread, exiting with an uncaught exception (group = 0x4 001e9a8)

Does anyone know what I did wrong?

+6
source share
2 answers

Article author, Andy McFadden, give me advice:

It tries to create a .odex file in / data / dalvik -cache. You will need to run as root or have insecure / Data / Dalvik cache.

As soon as I connected my device (for example, using SuperOneClick), it will work!


Comment by @domen: you really don't need to be root. You can set the ANDROID_DATA environment variable, and it will put it there. That is, mkdir /data/local/tmp/dalvik-cache , export ANDROID_DATA=/data/local/tmp .

+10
source

It seems you are trying to run it as a jar file from an SD card. You need to use the tools to create it as an apk file. This converts from Java bytecodes to Dalvik codes and reorganizes the contents of the file.

0
source

Source: https://habr.com/ru/post/889171/


All Articles