I am trying to run a simple command line java application on dalvikvm using the these instructions. I am running as root so it is not a permissions issue.
Here is the application code:
import android.os.SystemClock;
/**
* Command that sends key events to the device, either by their keycode, or by
* desired character output.
*/
public class MWE {
public static void main(String[] args) {
System.out.println(SystemClock.uptimeMillis());
}
}
When I run this on dalvikvm, I get the following error message:
java.lang.NoClassDefFoundError: android.os.SystemClock
at MWE.main(MWE.java:8)
at dalvik.system.NativeStart.main(Native Method)
Here is the command that I run, which works for the normal Hello World version of the above application.
/system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar -classpath /data/local/tmp/MWE.jar MWE
My current conclusion is that android.os.SystemClock
does not live inside core.jar
. I have speculatively tried to add framework.jar
and framework-res.jar
as well, but I get the same error.
- Which of the jars under
/system/framework
holds the classandroid.os.SystemClock
? - In general, is there a place that has a class-to-jar mapping for deployed jars in Android?
On my device (HTC One M8) android.os.SystemClock is in /system/framework/framework3.jar. I believe framework is separated into multiple jars because of the 65k method limit on classes.dex. android.os.SystemClock may be in a different jar on different android devices.
Steps I used to find where android.os.SystemClock was located:
I then decompiled classes.dex to a jar with DexToJar and viewed the packages inside the jar using JD-GUI (you could just open it as a ZIP file, jd-gui is not necessary and for windows only)