They weren't random. They were alphabetical. The first letter of the name always shifted to the next letter in the alphabet.
• Cupcake (Android 1.5)
• Donut (Android 1.6)
• Eclair (Android 2.0–2.1)
• Froyo (Android 2.2)
• Gingerbread (Android 2.3)
• Honeycomb (Android 3.0–3.2)
• Ice Cream Sandwich (Android 4.0)
• Jelly Bean (Android 4.1–4.3)
• KitKat (Android 4.4)
• Lollipop (Android 5.0–5.1)
• Marshmallow (Android 6.0)
• Nougat (Android 7.0–7.1)
• Oreo (Android 8.0–8.1)
• Pie (Android 9)