Galaxy Nexus does not charge when powered on, but it charges properly when powered off. Phone doesn't detect USB connection also. This happened without any reason. Phone is not rooted.
Tried different cable, charger, everything.
Do you happen to be using a 3rd party charger?
500mAh chargers cannot charge the Nexus while on, 1Ah chargers can but might struggle. I recommend chargers with 1.5Ah for charging high-end devices
Alternatively, the problem might lie with the power management of your ROM. Have you also installed an app recently before this happened?