Thanks!
Stay away from Samsung (their Knox security stuff and custom bootloader is nasty, Samsung deviates quite a lot from Android standards under the hood and their ODIN firmware flash tool isn't available publicly and cracked versions only for Windows), Xiaomi and Huawei devices (different partition layout, custom bootloader) and obscure Chinese no-name devices as for them you will have to do a lot of leg work regarding drivers or even basic tooling setup on your own.
For development, stay the hell away from Windows if you can, if possible also from macOS. You're best served with a Linux machine.
If you stay out of the weeds in the community and focus on the technical aspects, you can easily get a supported device up and running with your own signing key, update server, and everything else needed.
I did for years, before switching to GrapheneOS.
Its a really comprehensive hand-holding guide, written in a very engaging way:
There is also the mainlining guides at postmarketOS wiki, though these are harder to understand in my opinion:
If your goal is just to peak behind the curtain and see how those things gets built other comments will probably be more relevant than mine.
You'll need a pretty beefy Linux machine 200GB SSD storage, 32GB RAM, >8 CPU cores is recommended. You can go lower, but it becomes painful for development. ROM developers with less resources than that build on VPS.
If you want to start developing things Android-side (which means not the hardware/driver parts), I recommend:
- Use GSIs (Generic System Image) -- often on custom rom, it's a pain to build device-specific ROMs because you're always missing parts, and dependent on just the one developer maintaining that device. GSIs are more likely to be less painful to work with
- You can launch Android Studio inside AOSP using aidegen (I don't remember the exact syntax). For development on app-side (like if you want to change the UI) this will help a lot (but eat even more RAM)
- Android build system is very robust when it comes to incremental build, you should never have to clean anything. Maybe in some cases you might need `make installclean`, but except in horrible cases, that's all.
- You can build and replace specific components. For instance, if you just want to do quick cycle development on SystemUI, you can do `make SystemUI` to just build SystemUI, and replace it on your device with `adb root; adb remount; adb push out/target/product/xxxx/system/priv-app/SystemUI/SystemUI.apk /system/priv-app/SystemUI/SystemUI.apk` and soft-reboot android with `adb shell 'stop;start'`. Some components are APKs that can simply be installed, in which case you don't even need to soft-reboot android, and adb install -r out/target/product/xxxx/system/priv-app/Settings/Settings.apk` will do the trick
If you start developing "long term", consider that AOSP changes A LOT from one version to another, and Google has really no remorse to break stuff inside AOSP (not blaming, just stating), so always consider making apps rather than changing things inside Android framework. (Android has a notion of "system" and "privileged" apps, that can do a lot more than standard apps. The API you need to use in that case is not guaranteed, but it's less likely to move). If you can't make things into apps, then implement your feature with the lowest possible entry points coming from AOSP.
Once you got your first builds up and running, started trying to develop changes and know what change you want to do, feel free to ping me for pointers: phh on libera or @phhusson on telegram
FWIW, if it's of any use, a "oneliner" to build my AOSP GSI (so a "pure" AOSP, that will work on 95%+ of Android devices that are less than 4 years old): mkdir build; cd build; repo init -u https://android.googlesource.com/platform/manifest -b android-12.1.0_r14 ; git clone https://github.com/phhusson/treble_manifest -b android-12.0 .repo/local_manifests; repo sync -j12; (cd device/phh/treble;bash generate.sh);. build/envsetup.sh ; lunch treble_arm64_bvS-userdebug; make -j128
And image appears in out/target/product/phhgsi_arm64_ab/system.img
You'll need to figure out which model you have though