Solve flutter doctor android licenses error
Life as a programmer seems sometimes like a pain (luckily a true programmer loves such a life :). You could spend hours only to fix a small error. That happened to me recently. Suddenly flutter doctor threw error of android licenses (see the screenshot above).
I spent hours browsing for solution on the web (esp. stockoverflow.com). Unfortunately some accepted solutions there didn't really solve the problem I had. Therefore I feel the need to document it here to help other users who happen to face the same issues.
In short: simple "export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'" as some have suggested doesn't work!
These are the steps that solve the issue (not inside the Android Studio terminal, because Android studio has its own jdk version):
1. Install openjdk8: sudo apt install openjdk-8-jdk
2. Select java8 as default: sudo update-alternatives --config java and select jdk8.
3. make sure java8 is default by checking java -version
4. Set java home: export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
5. Type the following: unset JAVA_OPTS
6. Run the doctor: flutter doctor --android-licenses (see the result in the screenshot below)