Anyone know steps to replace frameworks.jar and relevant libraries on Android Marshmallow device?
My work is to modify Android Marshmallow framework source code, do full-build then update to device then verify result. It takes about 1,2 hours each time.
It is OK if I do it 1,2,3 times but actually I had to repeat it even 100 times if my modification not work. But I only modify only a small piece of code in frameworks/ so I think it would save me much time if I can rebuild only frameworks/ module in Android code and replace only frameworks/ part in device.
I know how to use mmm
to rebuild just frameworks/ module. But I don' know how to replace frameworks/ part in device because just replace frameworks.jar not work in Marshmallow case.
Assuming you're modifying things under frameworks/base/
, as it's where framework.jar
comes from, the steps I use are:
If you already have a full-build, use mm
command in the directory where you're modifying any code. It's faster than mmm
since it doesn't compile framework dependencies again.
Go to <aosp-root>/out/target/product/<product-name>/system/framework/
directory and get framework.jar
and services.jar
items.
Go to <aosp-root>/out/target/product/<product-name>/system/lib/
directory and get any libandroid*.so
file.
With device already rooted, adb push *.jar /system/framework/.
adb push *.so /system/lib/.
Factory reset the device and reboot it.
Changes made on your framework might work now. If your target device is 64 bits, replace lib by lib64 on above destinations.
Above steps will vary according to what we modify inside AOSP framework. Here a quick description on what goes inside each file:
framework.jar
: APIs accessible to applicationsservices.jar
: Implementation of managers and system services located under frameworks/base/services
.libandroid*.so
: Libraries generated from native code (C/C++) like the .cpp files located at frameworks/base/core/jni
. But, in general, each Android.mk
inside frameworks will generate at least one output named by the LOCAL_MODULE
variable and the type of the module depends on the following include instruction:
# JAR file
include $(BUILD_JAVA_LIBRARY)
# Library to be used by other modules
include $(BUILD_SHARED_LIBRARY)
# Executables
include $(BUILD_EXECUTABLE)
For example, the frameworks/base/cmds
folder generates a Java library and an executable for each item inside it, like the pm
command commonly used to install apps via ADB. In any case, the rule is: Java libraries go to /system/framework/
, Shared libraries go to /system/lib/
and executables go to /system/bin
.
More official information about Android.mk
can be found here, but it doesn't cover all variables and macros used by Android Build System, I get most of that info from AOSP code itself.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With