1. Weak hip and leg muscles
Especially weak glutes and quadriceps can lead to poor alignment of the kneecap. Strengthen your glutes and quads in the gym.
Something else that may help relieve knee pain is icing with an ice pack.
Make sure to place a thin towel between your skin and the ice pack to prevent frostbite or skin damage.