RK3399开机碰到卡在开机logo,出错日志如下:
01-18 09:43:09.362 24822 24822 E Zygote : Zygote died with exception
01-18 09:43:09.362 24822 24822 E Zygote : java.lang.UnsatisfiedLinkError: Unable to create namespace for the classloader dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/services.jar", zip file "/system/framework/ethernet-service.jar", zip file "/system/framework/wifi-service.jar"],nativeLibraryDirectories=[/system/lib64, /vendor/lib64, /system/lib64, /vendor/lib64]]]: android_init_namespaces failed: error initializing public namespace: a library with soname "libaudiorecord.so" was not found in the default namespace
01-18 09:43:09.362 24822 24822 E Zygote : at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:54)
01-18 09:43:09.362 24822 24822 E Zygote : at com.android.internal.os.ZygoteInit.createSystemServerClassLoader(ZygoteInit.java:571)
01-18 09:43:09.362 24822 24822 E Zygote : at com.android.internal.os.ZygoteInit.handleSystemServerProcess(ZygoteInit.java:547)
01-18 09:43:09.362 24822 24822 E Zygote : at com.android.internal.os.ZygoteInit.startSystemServer(ZygoteInit.java:699)
01-18 09:43:09.362 24822 24822 E Zygote : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
01-18 09:43:09.362 24822 24822 D AndroidRuntime: Shutting down VM
出错信息里面比较关键的是android_init_namespaces failed: error initializing public namespace: a library with soname “libaudiorecord.so” was not found in the default namespace。
发现在/system/lib与/system/lib64下均没有libaudiorecord.so这个库。
再看几个public.libraries.txt配置里面是有增加这个库的白名单的。
public.libraries.so一共有三个,位置分别是在:
/system/etc/public.libraries.txt
/vendor/etc/public.libraries.txt
如下图:
R61H:/ $ cat /vendor/etc/public.libraries.txt
libGLES_mali.so
librga.so
libvdk.so
libaudiorecord.so
在devices.mk里面把libaudiorecord.so的编译打开,系统能正常开机。
应用理论上只可以访问NDK提供的本地库和应用自带的本地库。但实际上应用也经常需要使用系统库,每个应用都将系统库打包到自己中未免太浪费了。所以Android还提供了应用访问系统库的方法,通过public.libraries.txt设置白名单。
看起来public.libraries.txt定义的必须实际上要有对应的so库与之对应,否则zygote会出错,具体流程代码后续补上。