Just bake new panels into the cost of a new roof. It's probably time for both after 25 years.
What sort of roofing lasts 25 years?
Composition roofs need to be replaced when they are worn out and not before that. Good materials competently installed could last 50 years, more in mild climates. If you have the kind of weather that will wear down a roof in 10 years you probably cannot have solar panels.