AOSP PinyinIME cannot be built as is because it uses non-exported API. That’s easy to fix, I actually made it compatible with Jelly Bean and later: relan / PinyinIME · GitLab
But that is software from Gingerbread era and it will require a lot of efforts to make it look and work like a modern keyboard.
Maybe a better approach would be adding pinyin support into LatinIME (Google maintains it quite well). After all, you use latin letters to enter text with pinyin.