I'm having the same problem right now. I believe the problem is the project's JDK version and what is installed on the computer.
Recently a colleague was using version 23.x and we had to change to 21.0.5 for the project. This solved the problem exactly, but it was when running and not when generating the APK/Bundle.