I am assuming you do not have Ukrainians family members and do not have permanent residency in the Ukraine.
In order to be entitled to a resident permit according to paragraph 24 of the Residency Law (which is the permit Ukrainians generally receive), it would have to be the case that it was not possible or safe for you to return to your home country. For this the authorities examine your individual circumstances, e.g. which home country, health concerns, young children or other vulnerable individuals etc.
If you are not entitled to a permit according to paragraph 24, you have the option to apply for a permit on other grounds, for example working, studying, learning German. There is also the option of applying for asylum but you should seek some expert advice if intending to do so.
Here is a detailed overview of the options in such cases (via online translation):