Hi,
you need to work the other way around.
Work with the lowest possible verson of Unity ( 4.7) and thing will be compatible, the otherway is not possible,
or do two or more packages, one for 4.7 and one for 5 and up.
I strongly advice NOT to use global variables when you publish packages, create a project that doesn't need it, it will be a lot simpler to deploy.
If you need tricks on avoiding global variables, let me know, I can hint you in several directions.
Bye,
Jean