Behavior 

When deploying a Apex class from source to target it is possible to get the error in the format of 

Invalid api version:<insert version number>

 for example:

Invalid api version:45.0

Root cause

This is most likely because the target org has not been upgraded to the higher version number yet that is available in the source.

This is where the Apex class version number is specified:

Resolution 

You can change the version number on the source to one that is compatible with the target org. If your target is on version 44.0, reduce the version number of the Apex class in the source to 44.0 and your deployment error should be resolved.

Let me know if that helped you out using the reactions below!

Did this answer your question?