This article explains the R.java file and Dalvik virtual machine in Android. This file is automatically generated by the Android asset packaging tool that contains resource ids of all the resources. If you create any component in the activity_main.xml file then the ids of all the components are automatically generated inside the R.java file.
The following is an example of a generated R.java file in Android Studio that contains the ids of the resuorce component. I just use an example of when we create a button in our XML file. The R.java file is then created with id as in the following:
Dalvik virtual machine
Dalvik is the name of a town in Iceland that was Written by Dan Bornstein
. The Dalvik Virtual Machine runs the .dex file provided by the dex compiler
. Let's see the process.
First, the Java class file goes to the Java compiler and this compiler converts the Java file into the class file.
Now the dx (Dex Compiler) tool converts the .class file into the .dex file. This .dex file will run on the Dalvik Virtual Machine and then it is converted into the .apk file by the Android asset packaging tools.
The following figure shows how the Dalvik Virtual Machine works.