When your Android sometimes crashes while charging, try ChargingKeepalive. It keeps Android alive with a wake-lock while it is charging. Before installing please check if keeping your phone alive is sufficient for solving your problem. In developer settings activate "keep active". This will keep your phone and display alive while charging.