top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the reason of converting java bytecode to Dalvik bytecode in android?

+2 votes
What is the reason of converting java bytecode to Dalvik bytecode in android?
posted Oct 6, 2016 by Bhagyashree R

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Simple answer is android does not understand .class format of Oracle JVM bytecode, it understand Dalvik byte-codes.

The .class files contain standard Oracle JVM Java byte-codes. But Android devices don’t use this byte-code format. Instead, Android has its own distinct byte-code format called Dalvik. Dalvik byte-codes, like Oracle JVM byte-codes, are machine-code instructions for a theoretical processor.

The compilation process needs to convert the .class files, and any .jar libraries into a single classes.dex file containing Dalvik byte-codes. This is done with the dx command.

answer Oct 6, 2016 by Salil Agrawal
How can we ensure it will not understand .class format?
Not sure if there is a way or not...
0 votes

Android uses Dalvik Virtual Machine (DVM) which requires a special bytecode. First of all, we have to convert Java class files into Dalvik Executable files using an Android tool called “dx”. In normal circumstances, developers will not be using this tool directly and build tools will care for the generation of DVM compatible files.

answer Jun 1, 2017 by Karthick.c
Similar Questions
0 votes

I was experimenting something with Android native code and it needs to access a file in dalvik/vm folder from a .cpp file in frameworks/base/core/jni ... I would like to know if this is even possible through #include or some other technique. I think #include may not be the right way to do it and wold like to know if my purpose can be somehow achieved.

0 votes

I tried to run Dalvik in portable mode by setting /data/local.prop as follows:

dalvik.vm.execution-mode = int:portable

But after I reboot the device (which is a Nexus 7), app_process (hosting zygote) still starts in jit mode.

However, if I run:

adb shell stop
adb shell setprop dalvik.vm.execution-mode int:portable
adb shell start

Then app_process will run in portable mode. Is /data/local.prop deprecated or something is missing here?