Segmentation Fault executing pm on android

2019-05-22 18:27发布

问题:

I am able to execute pm from the adb shell fine, but I get a segmentation fault if I try and execute it from the terminal. I have read this thread which suggests a similar problem, but their solution doesn't seem to work.

The stack trace is as follows:

01-22 04:04:39.356: D/AndroidRuntime(5059): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
01-22 04:04:39.356: D/AndroidRuntime(5059): CheckJNI is OFF
01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away
01-22 04:04:39.366: E/dalvikvm(5059): /system/framework/ext.jar odex has stale dependencies
01-22 04:04:39.366: I/dalvikvm(5059): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-22 04:04:39.366: D/dalvikvm(5059): Unable to process classpath element '/system/framework/ext.jar'
01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away
01-22 04:04:39.366: E/dalvikvm(5059): /system/framework/framework.jar odex has stale dependencies
01-22 04:04:39.366: I/dalvikvm(5059): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-22 04:04:39.366: D/dalvikvm(5059): Unable to process classpath element '/system/framework/framework.jar'
01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away
01-22 04:04:39.366: E/dalvikvm(5059): /system/framework/android.policy.jar odex has stale dependencies
01-22 04:04:39.366: I/dalvikvm(5059): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-22 04:04:39.366: D/dalvikvm(5059): Unable to process classpath element '/system/framework/android.policy.jar'
01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away
01-22 04:04:39.366: E/dalvikvm(5059): /system/framework/services.jar odex has stale dependencies
01-22 04:04:39.366: I/dalvikvm(5059): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-22 04:04:39.366: D/dalvikvm(5059): Unable to process classpath element '/system/framework/services.jar'
01-22 04:04:39.366: D/dalvikvm(5059): Trying to load lib libjavacore.so 0x0
01-22 04:04:39.376: D/dalvikvm(5059): Added shared lib libjavacore.so 0x0
01-22 04:04:39.376: D/dalvikvm(5059): Trying to load lib libnativehelper.so 0x0
01-22 04:04:39.376: D/dalvikvm(5059): Added shared lib libnativehelper.so 0x0
01-22 04:04:39.406: I/dalvikvm(5059): DexOpt: Some deps went away
01-22 04:04:39.406: E/dalvikvm(5059): /system/framework/pm.jar odex has stale dependencies
01-22 04:04:39.406: I/dalvikvm(5059): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
01-22 04:04:39.406: E/appproc(5059): ERROR: could not find class 'com.android.commands.pm.Pm'
01-22 04:04:39.406: E/JNIHelp(5059): Native registration unable to find class 'android/debug/JNITest', aborting
01-22 04:04:39.406: A/libc(5059): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 5059 (app_process)

回答1:

  1. Check BOOTCLASSPATH of your init.rc. BOOTCLASSPATH must include /system/framework/ext.jar and /system/framework/framework.jar and so on.

  2. Check DEXPREOPT_BOOT_JARS of build/core/dex_preopt.mk. DEXPREOPT_BOOT_JARS must include ext and framework and so on.

  3. The order of all items on BOOTCLASSPATH must be equal to the order of all items on DEXPREOPT_BOOT_JARS.