Affection and friendship are two separate things! Friendship is gathered from things like levelling, using items or giving massages. Some examples:
- Walking 128 steps 2 / 2 / 1
- Wing 3 / 2 / 1
- Vitamin 5 / 3 / 2
- Message 5 (74% of the time) 10 (20%) 30 (6%)
- EV lowering berries 10 / 5 / 2
- Soothing bag (from Super Training) 20
The first number is with a friendship between 0 and 99. The second between 100 and 199, and the third 200-255. Information how much exactly and what different kinds is on Bulbapedia.
Pokemon Amie is for affection. The only Pokemon right now that evolves with affection is Eevee (into Sylveon, while also knowing a Fairy type move). The different effects are the following (from Bulbapedia):
At affection level 2 and higher
- a Pokémon will gain 1.2 times the normal experience from battles.
At affection level 4 and higher, a Pokémon can sometimes:
- Avoid attacks, even when they have 100% accuracy. This can activate multiple times per turn.
- Endure attacks that could otherwise make it faint and survive with 1 HP (including confusion damage). This can activate multiple times per turn.
- Shake off status conditions at the end of the turn.
At affection level 5 and higher, a Pokémon can sometimes:
- Have higher chance of critical hits.
How do you evolve your Riolu at level 2?
So if you want to evolve your Riolu at level 2, you can give him berries, or walk an enormous amount of steps. You'll need a friendship of 220 before it evolves, and you gain 1 friendship every 256 steps. That will be 56064 steps. You can also use vitamins or EV lowering berries to reduce this amount of steps. Good luck!