我尝试在模拟器棉花糖中构建pm
模块。
我选择aosp 6.0.1_r1 x86_64,然后在AVD中创建模拟器Android 6 x86_64(无播放)。
我确实成功地分别使用framework
和pm
制作了LANG=C make framework -j4 VERBOSE=1
和LANG=C make pm -j4 VERBOSE=1
两个模块。我还尝试通过简单地推送framework.jar来进行测试->重新启动似乎没有崩溃。
现在我尝试pm:
$ adb push out/target/product/generic_x86_64/system/framework/oat/x86/pm.odex /system/framework/oat/x86/
$ adb push out/target/product/generic_x86_64/system/framework/oat/x86_64/pm.odex /system/framework/oat/x86_64/
$ adb push out/target/product/generic/system/framework/pm.jar /system/framework/
重新启动模拟器后,运行pm
命令仅显示“已中止”,什么也不做。
root@generic_x86_64:/ # pm
Aborted
如何调试它?我想我可能错过了一些步骤,但是我对aosp还是陌生的。
构建与仿真器中pm.odex
的大小相等:
xb@dnxb:~/Downloads/pm/emulator/2$ ls -l
total 328
-rw-r--r-- 1 xiaobai xiaobai 168704 Mac 25 18:02 pm_64.odex
-rw-r--r-- 1 xiaobai xiaobai 160236 Mac 25 18:02 pm.odex
xb@dnxb:~/Downloads/pm/emulator/2$
$ ls -la out/target/product/generic_x86_64/system/framework/oat/x86/pm.odex
-rw-r--r-- 1 xiaobai xiaobai 160236 Mac 25 17:54 out/target/product/generic_x86_64/system/framework/oat/x86/pm.odex
$ ls -la out/target/product/generic_x86_64/system/framework/oat/x86_64/pm.odex
-rw-r--r-- 1 xiaobai xiaobai 168704 Mac 25 17:54 out/target/product/generic_x86_64/system/framework/oat/x86_64/pm.odex
logcat显示:
03-26 04:53:24.996 2461 2461 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
03-26 04:53:24.998 2461 2461 D AndroidRuntime: CheckJNI is ON
03-26 04:53:25.011 2461 2461 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
03-26 04:53:25.018 2461 2461 E appproc : ERROR: could not find class 'com.android.commands.pm.Pm'
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:511)
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:469)
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410]
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] in call to NewGlobalRef
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] "main" prio=5 tid=1 Runnable
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] | group="main" sCount=0 dsCount=0 obj=0x12c2d100 self=0x7f7c3cd7ba00
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] | sysTid=2461 nice=0 cgrp=default sched=0/0 handle=0x7f7c406ed200
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] | state=R schedstat=( 0 0 0 ) utm=14 stm=0 core=1 HZ=100
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] | stack=0x7fff163c2000-0x7fff163c4000 stackSize=8MB
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] | held mutexes= "mutator lock"(shared held)
03-26 04:53:25.022 2461 2461 F art : art/runtime/java_vm_ext.cc:410] native: #00 pc 00000000005678e7 /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+215)
...
如果我尝试构建dumpsys
模块,即/system/bin/dumpsys
,则运行没有问题。而且,如果我使用原始的pm.odex
复制回来,也没有问题,甚至不需要重新启动。
我的平台是Ubuntu 18.04。任何帮助将不胜感激。