Do you currently run P, Q, R or S android underlayer ?
Do you currently run stable or dev build ?
Does your bootloader locked or unlocked ?
In the worst cases (Q or locked bootloader), you will need to format the /data partition…
and so, loose you installed apps and personnal things to recover a working phone