Currently I am trying to set up my Android Studio environment for Flutter and I am unable to update sdkmanager or else I would obtain the following errors :

Error: Could not find or load main class

This error affects the rest of my tools folder (sdkmanager,avdmanager, basically any .bat I run within that folder) as well.

What I have tried:

  • Clean installed and reinstalled Android Studio numerous times
  • Uninstalled and reinstalled Java numerous times (Version 13)
  • Change parts of my sdkmanager.bat and android.bat based on the other stack overflow questions--since this did not work, I reverted them back to the original code
  • Run as admin with command prompt and powershell
  • Installed JDK 8 because Flutter doesn’t like other versions of Java
  • Changed my environmental variables -these are the variables in relation to Android Studio and Java as of now

CLASSPATH - %JAVA_HOME%\lib;

JAVA_HOME - C:\Program Files\Java\jdk-13.0.1

PATH - C:\Users[username]\AppData\Local\Android;C:\Program Files\Java\jdk-13.0.1\bin;C:\Windows\system32;C:\Users[username]\Documents\flutter\bin;C:\Program Files\Git\git-cmd.exe;

Updates

For majority of the .bat files, %JAVA_OPTS% is causing the issue, I’ve tried to set a JAVA_OPTS variable but that does not help

Solution

I deleted %JAVA_OPTS% from the .bat file and it seems that was the issue, but I don’t think I’m supposed to delete that part.