Fastest way to test modified Android source code?
Asked Answered
A

2

6

I am going to buy the Nexus 5 when it is available in my country. I then want to make changes (mostly UI) to the Android source code and run it on my phone.

My question is: how do I fastest test the code I have modified? Do I need to compile and create a ROM and flash it after every change to my phone or may I use the emulator and "quick-build" to it?

To clarify: I will download the Android source code and modifiy it. I will change UI stuff so that it suits me. After that I would like to test what I have written, preferably in the device but the emulator is also feasible.

I want to test the Android platform changes. Because I modify the source code I have to create a ROM and flash it to the device as the Android system cannot be installed as an .apk.

What is the fastest way to test the changes? It would be annoying to have to create a ROM and flash it EACH time I make a change to the source code, for instance test that my new UI works accordingly.

Is there some way to do this faster?

Astrogate answered 8/11, 2013 at 7:58 Comment(3)
I doubt that there is a faster way, you are changing the system, it make sense you have to reinstall it everytimeUmbria
Where exactly in platform/framework are you making the changes?Alrich
@shoerat I was gonna do some changes in platform_frameworks_base/core/java/android/widget/Astrogate
P
5

It depends at what level you are doing changes. If you are doing frameworks/base/core changes then you can navigate to your frameworks/base/core portion of your AOSP project and do an incremental build by doing (ensure that you initialized your build environment: . build/envsetup.sh in the root of your AOSP source directory):

mm -B

This will build the component you are in, which will be framework's framework.jar/ext.jar/etc

After this compiles then you can do (Be on the lookout for Errors during compilation):

adb root;
adb remount;
adb sync;
adb shell stop;
adb shell start

This will update the framework jar file on the device and then you should be able to see your changes.

Note

This will ONLY work if your current build is the SAME as the AOSP code you are building, otherwise you will have to push the framework.jar file into the system/framework/ portion of your device (which requires root).

Posthumous answered 8/11, 2013 at 9:2 Comment(5)
Thank you for the answer. I just want to confirm though, the way everything works, if I change the frameworks/base/core, build it and receive a .jar file with everything included from that directory, I then move that .jar file to the system and then "restart" or "reload" the .jar? Of course it will reload more, like all the components?Astrogate
The framework.jar replacing will replace the implementation with the new framework.jar, so yes. You MUST restart zygote through shell stop and shell start to load the new framework.jar file.Posthumous
Thank you once more for the detailed answer!Astrogate
I know this is a late reply, but I tried the following and it does not work. Please refer to this question if you want.Astrogate
Actually I got this working, not sure how though. More details at the top of my other answer pasted above.Astrogate
A
0

I think it's better to recompile the whole source code after the modification.
I suggest to use the AOSP instead of hacking the factory image, no ROM will be needed, just flush with ADB.
The first build will cause a lot of time and space, but the android build system will only build the modified code when rebuilding.
Note: GPS, Sensor are not functional by default, as third part device driver is not included in AOSP.

Adventitia answered 8/11, 2013 at 8:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.