I had to deal with this error for months and finally I came up with some sort findings about the root of this error. In my experience there are few possible cases.
If you see this error on your visual studio errors window this is the check list to follow.
Case 1 : Temporary caching issues in visual studio.
- Try to right click the project and rebuild.
- If you cant rebuild the project restart visual studio. Then try again.
- If your project is building successfully that means its a temporary caching problem.
Case 2 : System variables of visual studio not up to date.
- Go to tools >> options >>> Tools For Apache Cordova >>> Environment Variable Overrides .
- Check all the paths for your environment variables are correct. If not please apply the correct path.
- And try to rebuild the project.
Case 3 : Android SDK is not up to-date.
- First delete the andoird folder in platforms folder.
- Try to build your project.
- Now you will see more details about the error.
- So install or update any component of sdk that has any errors in visual studio error window.
Follow these steps by the above order. That will save you lot of time.