Android11快速编译并替换framework.jar
在Android11之前修改了framework相关代码,只需make framework就可以编译出framework.jar。在Android11,这个编译命令不起作用了,根据framework/base/目录下Android.bp中的提示:
java_library { name: "framework-minus-apex", defaults: ["framework-defaults"], srcs: [":framework-non-updatable-sources"], installable: true, ...... // For backwards compatibility. stem: "framework", apex_available: ["//apex_available:platform"], visibility: [ "//frameworks/base", // TODO(b/147128803) remove the below lines "//frameworks/base/apex/blobstore/framework", "//frameworks/base/apex/jobscheduler/framework", "//frameworks/base/packages/Tethering/tests/unit", ], } // This "framework" module is NOT installed to the device. It's // "framework-minus-apex" that gets installed to the device. Note that // the filename is still framework.jar (via the stem property) for // compatibility reason. The purpose of this module is to provide // framework APIs (both public and private) for bundled apps. // "framework-minus-apex" can't be used for the purpose because 1) // many apps have already hardcoded the name "framework" and // 2) it lacks API symbols from updatable modules - as it's clear from // its suffix "-minus-apex".
可以看到framework变为了framework-minus-apex,通过stem属性使编译出来的模块还叫framework.jar,这样修改的目的一个是为了向后兼容以前的jar名称,一个也是为了表示现在framework是减去了apex的模块,所以带个minus-apex的后缀。
那么编译的时候就要换成下面的命令:
make framework-minus-apex
编译出framework.jar后,先用下面的命令remount:
adb root;adb disable-verity;adb reboot;adb wait-for-device;adb root;adb remount
然后把framework.jar push到system/framework/下面,同时还要删除这个目录下面的oat,arm,arm64三个目录(不删除会一直卡在开机动画),最后再运行下面的命令重启zygote,这样新替换的framework.jar就生效了。
adb shell stop;adb shell start;
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/superlee1125/article/details/115491698