I have been in this exact same situation myself, Shroomster.
Solution: you need to level it up during the day in the game, as the game determines "during the day" as when the sun is out in the game. In Moon, the sun is way up in the virtual sky at 6:00 PM where it would normally be setting in real time; that's when Riolu will be ready to train.
Sorry if I said "game" too much. =P