简体   繁体   English

哪个部署的jar包含android.os.SystemClock?

[英]Which deployed jar contains android.os.SystemClock?

I am trying to run a simple command line java application on dalvikvm using the these instructions . 我正在尝试使用这些指令在dalvikvm上运行一个简单的命令行Java应用程序。 I am running as root so it is not a permissions issue. 我以root用户身份运行,因此这不是权限问题。

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: 在dalvikvm上运行此命令时,出现以下错误消息:

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. 这是我运行的命令,该命令适用于上述应用程序的普通Hello World版本。

/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 . 我目前的结论是android.os.SystemClock不在core.jar内部。 I have speculatively tried to add framework.jar and framework-res.jar as well, but I get the same error. 我已经推测性地尝试添加framework.jarframework-res.jar ,但是我遇到了同样的错误。

  1. Which of the jars under /system/framework holds the class android.os.SystemClock ? /system/framework下的哪个jar包含android.os.SystemClock类?
  2. In general, is there a place that has a class-to-jar mapping for deployed jars in Android? 总的来说,有没有一个地方为Android中已部署的jar提供了类到jar的映射?

On my device (HTC One M8) android.os.SystemClock is in /system/framework/framework3.jar. 在我的设备(HTC One M8)上,android.os.SystemClock位于/system/framework/framework3.jar中。 I believe framework is separated into multiple jars because of the 65k method limit on classes.dex. 我相信,由于classes.dex的方法限制为65k,框架被分为多个jar。 android.os.SystemClock may be in a different jar on different android devices. android.os.SystemClock可能在不同的android设备上的不同jar中。

Steps I used to find where android.os.SystemClock was located: 我用来查找android.os.SystemClock的位置的步骤:

adb pull /system/framework/<filename>.jar

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) 然后,我使用DexToJar将classes.dex反编译为一个jar,并使用JD-GUI查看该jar中的软件包(您可以将其作为ZIP文件打开,不需要jd-gui,仅用于Windows)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM