MacOS 10.15: Android Studio 3.5.1:
The solution that works for me was to use the Java Environment tool jenv
(installed via homebrew). This tool changes the $JAVA_HOME when one switches between java versions.
In my case I have multiple Java versions installed and the current global version in use was the default. I also found it necessary to comment out the $JAVA_HOME environment variable in my .bash_profile
when using this tool.
In Terminal, I entered jenv global 1.8
to get java 1.8 running instead of a later version (I have multiple versions installed).
After that:
flutter doctor --android-licenses
OR
sdkmanager --licenses
both work fine.
Note: You may need to exit and reopen your Terminal shell if you have to redefine the $JAVA_HOME environment variable.