Since I am using Linux and ended up here, I'll give an answer to this question for those using Linux who could end up here.
If you're using Linux, your problem might be related to Tilde expansion.
Thomas Augot's answer pointed me in the right direction.
My problem was I was using ~ to substitute my home directory and sdkmanager didn't get correct value for --sdk_root, most probably due to some problem with Tilde expansion and had created a directory named ~ in my home directory where it installed one package, namely build tools. After I moved them to my sdk root, I was able to accept licenses and continue with my work.