Replace only framework.jar & its relevant libraries on Android MarshMallow

六眼飞鱼酱① 提交于 2019-12-22 04:02:03

问题


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.


回答1:


Assuming you're modifying things under frameworks/base/, as it's where framework.jar comes from, the steps I use are:

  1. 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.

  2. Go to <aosp-root>/out/target/product/<product-name>/system/framework/ directory and get framework.jar and services.jar items.

  3. Go to <aosp-root>/out/target/product/<product-name>/system/lib/ directory and get any libandroid*.so file.

  4. With device already rooted, adb push *.jar /system/framework/.

  5. adb push *.so /system/lib/.

  6. 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.

Explanation

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 applications
  • services.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.



来源:https://stackoverflow.com/questions/36005272/replace-only-framework-jar-its-relevant-libraries-on-android-marshmallow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!