When my Nexus 4's battery is less than 5%, it won't charge while connected to my PC, but I can charge by plugging my Nexus 4 the wall adapter.
I believe it is a hardware problem. Can you help me?
Your computer’s USB port have lower energy output than your wall charger. There is nothing you can do about this other than getting a new computer with higher power USB power output.
Do note that your phone is actually charging even when it says it is not. It is just slower. If you keep the screen off and the device idle, it should be fully charged after some hours. This will be much slower than using a higher power output source.