Failed to apply plugin id 'android'

I have having trouble with ionic build android. It is giving me this error below.


I have tried everything from reinstalling android SDK, reinstalling ionic and cordova, checking the path variables etc.

All the build tools in my SDK manager have been installed and I cannot seem to find the root of this problem.

Any help would be appreciated.