赞
踩
一、不包含so库的简单apk:
完全可以预装到system/app目录下(也就是系统app),运行时不会有找不到so库的错误;
二、包含so库的apk:
如果按照普通的apk一样预装到system/app目录,则会报错:
java.lang.UnsatisfiedLinkError: Couldn't load libXXX from loader .........findLibrary returned null;
对于发生这种情况的原因是system app在系统启动加载时不会加载so;
无法加载so导致失败参考log
08-26 21:40:37.880 23046 23046 D cr_LibraryLoader: [LibraryLoader.java:512] Loading with the System linker. 08-26 21:40:37.884 23046 23046 E ContentShellActivity: ContentView initialization failed. 08-26 21:40:37.884 23046 23046 E ContentShellActivity: org.chromium.base.library_loader.ProcessInitException: errorCode=2 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at org.chromium.base.library_loader.LibraryLoader.loadMainDexAlreadyLocked(LibraryLoader.java:522) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at org.chromium.base.library_loader.LibraryLoader.ensureMainDexInitialized(LibraryLoader.java:302) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at org.chromium.base.library_loader.LibraryLoader.ensureInitialized(LibraryLoader.java:286) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at com.access_company.nfbe.content_shell_apk.ContentShellActivity.onCreate(ContentShellActivity.java:363) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.Activity.performCreate(Activity.java:7807) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.Activity.performCreate(Activity.java:7796) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.os.Handler.dispatchMessage(Handler.java:107) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.os.Looper.loop(Looper.java:214) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at android.app.ActivityThread.main(ActivityThread.java:7356) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at java.lang.reflect.Method.invoke(Native Method) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/app/NFBE/NFBE.apk!/lib/armeabi-v7a/libcontent_shell_content_view.so" not found 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at java.lang.Runtime.loadLibrary0(Runtime.java:1071) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at java.lang.Runtime.loadLibrary0(Runtime.java:1007) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at java.lang.System.loadLibrary(System.java:1667) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at org.chromium.base.library_loader.LibraryLoader.loadWithSystemLinkerAlreadyLocked(LibraryLoader.java:476) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: at org.chromium.base.library_loader.LibraryLoader.loadMainDexAlreadyLocked(LibraryLoader.java:513) 08-26 21:40:37.884 23046 23046 E ContentShellActivity: ... 18 more 08-26 21:40:37.886 23046 23046 I ntent_shell_ap: System.exit called, status: -1
同时一般预置的第三方App都会把这个宏开关置为false,这样既可以避免提取odex出现异常导致App功能异常,也能节省一定空间消耗。编译生成的文件没有oat文件,也就意味着没有被提前优化。
mk文件中添加LOCAL_DEX_PREOPT := false把预编译关闭。
LOCAL_DEX_PREOPT := false // 不进行预先优化
LOCAL_DEX_PREOPT := true // 进行预先优化
08-27 13:52:41.859 7468 7468 E System : ****************************************** 08-27 13:52:41.860 7468 7468 E System : ************ Failure starting system services 08-27 13:52:41.860 7468 7468 E System : java.lang.IllegalStateException: Signature|privileged permissions not iALL_PACKAGES} 08-27 13:52:41.860 7468 7468 E System : at com.android.server.pm.permission.PermissionManagerService.syste 08-27 13:52:41.860 7468 7468 E System : at com.android.server.pm.permission.PermissionManagerService.acces 08-27 13:52:41.860 7468 7468 E System : at com.android.server.pm.permission.PermissionManagerService$Permi 08-27 13:52:41.860 7468 7468 E System : at com.android.server.pm.PackageManagerService.systemReady(Package 08-27 13:52:41.860 7468 7468 E System : at com.android.server.SystemServer.startOtherServices(SystemServer 08-27 13:52:41.860 7468 7468 E System : at com.android.server.SystemServer.run(SystemServer.java:537) 08-27 13:52:41.860 7468 7468 E System : at com.android.server.SystemServer.main(SystemServer.java:365) 08-27 13:52:41.860 7468 7468 E System : at java.lang.reflect.Method.invoke(Native Method) 08-27 13:52:41.860 7468 7468 E System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Run 08-27 13:52:41.860 7468 7468 E System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045) 08-27 13:52:41.860 7468 7468 D SystemServerTiming: MakePackageManagerServiceReady took to complete: 2118ms 08-27 13:52:41.861 7468 7468 E Zygote : System zygote died with exception 08-27 13:52:41.861 7468 7468 E Zygote : java.lang.IllegalStateException: Signature|privileged permissions not iALL_PACKAGES} 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.pm.permission.PermissionManagerService.syste 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.pm.permission.PermissionManagerService.acces 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.pm.permission.PermissionManagerService$Permi 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.pm.PackageManagerService.systemReady(Package 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.SystemServer.startOtherServices(SystemServer 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.SystemServer.run(SystemServer.java:537) 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.server.SystemServer.main(SystemServer.java:365) 08-27 13:52:41.861 7468 7468 E Zygote : at java.lang.reflect.Method.invoke(Native Method) 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Run 08-27 13:52:41.861 7468 7468 E Zygote : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045) 08-27 13:52:41.861 7468 7468 D AndroidRuntime: Shutting down VM 08-27 13:52:41.862 7468 7468 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main 08-27 13:52:41.862 7468 7468 E AndroidRuntime: java.lang.IllegalStateException: Signature|privileged permissionsn.INSTALL_PACKAGES} 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerServi 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerServi 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerServi 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.pm.PackageManagerService.systemReady 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.SystemServer.startOtherServices(Syst 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.SystemServer.run(SystemServer.java:5 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.server.SystemServer.main(SystemServer.java: 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller 08-27 13:52:41.862 7468 7468 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java 08-27 13:52:41.865 7468 7468 I DropBoxManagerService: add tag=system_server_crash isTagEnabled=true flags=0x2 08-27 13:52:41.869 7468 7468 I Process : Sending signal. PID: 7468 SIG: 9
如上log所示为未在白名单里,按照文件格式增入白名单即可。
android/frameworks/base/data/etc/privapp-permissions-platform.xml
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。