This is a difficult lesson for Greg to learn, but he starts to make progress by the end of the book. He begins to stand up to his bully, Fregley, and he starts to be more honest with his friends and family. He also starts to realize that he doesn't need to be perfect to be liked.
The book ends with Greg writing in his diary about how he's learned the ugly truth about himself. He's not perfect, but he's okay with that. He's also realized that he doesn't need to be perfect to be loved.
The solution to the book is for Greg to learn to love himself for who he is. This is a journey that he will continue to take throughout the rest of his life, but he is making progress.