I'm afraid you get my standard reply: it depends. Sorry!
Some aircraft have fantastically complex undercarriage; with others, it's little more than a stick with a wheel on the end. And that wheel is an added complication. Plus, there's the question of how strong the parts are - will they hold the model off the deck without help?
What I generally do is this. I paint the undercarriage bay on the airframe (unless it has undercuts, in which case I paint it before installation) and assemble and paint the undercarriage itself before I install it. If it has complex geometry that would make it tricky to paint it last, I see if there are sub-assemblies that can be painted first. If not, it has to painted one piece at a time and then assembled. (If you use an airbrush, this is less likely to be a problem.) In either of the latter two, I leave the mating surfaces unpainted or use superglue to assemble it - which I choose depends on how large the contact points are (and thus how strong they'll be). I always leave off the wheels, but paint and weather them before assembly.
Painting such small items will be problematic but they help you by almost always having a locating lug at the upper end. Insert this into the business end of a pair of Helping Hands and you can paint to your heart's content.
Then, at the best point in the build, I install the undercarriage legs but not the wheels, and weather the legs and bays in situ. This way the two are tied in and I don't have to worry about touching in afterwards. Choice of glue again depends on strength of join.
Finally, as close to the very end as possible, I attach the wheels. I always file flats or use pre-flattened wheels, so I always check-fit first. A piece of stiff plastic card is handy for this - it gives a flat surface without bowing and yet is light enough not to shift the wheels, so it acts as an upside-down "ground" and allows me to rotate the wheels til they're sitting right. As a rule I use slow-curing glue for this, again depending on how strong it needs to be. Multi-wheeled aircraft are handy because you can align the wheels using only one on each leg, then add their counterparts afterwards without needing to set them separately.
Alternatively, there's gear-up. Which is when you discover that no model company provides scale-thickness undercarriage doors ...