Java 1.6.0-25 and any other sun java is not required at all as Android Studio uses OpenSDK version of Java instead, which is included with Android Studio and installed by default. So you dont need to use any of the official java version at all!
Also if Android Studio want you to update project settings to newer settings in a project, then the project can cause fails to compile completly.
But if that was happens, its very easy to revert it again:
in File/Project Structure/Project
Make sure Android Grandle Plugin uses version 3.4.1 and Grandle version uses 5.1.1. We can uses a bit newer version here, but those versions should works and still works nicely today (has just released PowerUp Elevation today)!
Also im do heard androidx.appcompat:appcompat:1.1.0 is depreacted? howover line is still there and should not cause any trouble throught when that grandle versions above is using.
After that, open the grandle file again and sync. Then any missing sdk, cmake and ndk that is required should now been downloaded automatic. This take some time.