问题现象
Android无法正常启动,但是不影响native进程运行。主要影响zygote 初始化
pid: 8035, tid: 8035, name: main >>> zygote <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'Error preloading public library libcommonsystem_jni.so: dlopen failed: library "libcommonsystem_jni.so" not found'
r0 00000000 r1 00001f63 r2 00000006 r3 e979b830
r4 00001f63 r5 00001f63 r6 ffe7337c r7 0000010c
r8 e69a9fc0 r9 0000002f r10 00000071 r11 00000070
ip 00000041 sp ffe73368 lr e9727105 pc e971ee92
01-01 08:46:09.307 8035 8035 I zygote : option[46]=-Xfingerprint:qti/msmnile_gvmq/msmnile_gvmq:9/PQ1A.190105.004/ulixs11408240312:userdebug/test-keys
01-01 08:46:09.309 8035 8035 I zygote : VerifyImage: /system/bin/patchoat --input-image-location=/system/framework/boot.art --output-image-directory=/data/dalvik-cache/arm --instruction-set=arm --verify
01-01 08:46:09.405 8035 8035 F libnativeloader: Error preloading public library libcommonsystem_jni.so: dlopen failed: library "libcommonsystem_jni.so" not found
问题分析
这个需要从Android 启动开始分析,Java 世界的开始源于Zygote, Zygote 在起来的时候回去初始化一些动态,这个工作是由libnativehelper 完成。 libnativehelper 会从/system/etc/public.libraries.txt中来加载需要的动态库,后面的从Zygote孵化出来的进程就不需要重新加载。
问题根本原因,之前有个静态Java库会去System.loadLibrary() libcommonsystem_jni.so. 所以将libcommonsystem_jni.so配置到白名单中,使其可以方便的调用。但是现在换成其他方案的时候,移除此库。但是忘记将其从白名单中移除导致zygote无法正常初始化成功。
关于libnativehelper 可以参考:libnativehelper
问题解决
将libcommonsystem_jni.so 从 public.libraries.android.txt 中删除。文件位置如下:
/system/core/rootdir/etc/public.libraries.android.txt