Ionic build fails

Getting the following error when running 'cordova build android’

Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.ide.common.process
.ProcessException:

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

Tried running ionic cordova resources as mentioned in other solutions for the same question.

Whenever running the command it is asking for credentials. Even after entering the right credentials it is displaying the following error.

? Password: [hidden]
Request: POST https://api.ionicjs.com/login
Response: 422
Body:
{ link: null,
message: 'An error occurred while validating the request parameters.',
type: 'UnprocessableEntity',
details: [ { parameter: 'source', errors: [Object], error_type: 'required' } ]
}

Can somebody help please?