Android SDK Manager – Fix ‘Could Not Find or Load Main Class’ Error

androidandroid-sdk-managerandroid-studiofluttersdk

I am trying to install Flutter without Android Studio and here is what I did:

  • Installed Java 8
  • Installed and Unzipped Flutter SDK to C:\src.
  • Installed and Unzipped Android Command-line tools (sdkmanager) to C:\Android.
  • Added the environment variables (ANDROID_HOME: C:\Android)

Now when I try to run sdkmanager to install Android SDK, I get this error:

"Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli"

I have tried reinstalling Flutter sdk and the sdkmanager with no luck.

Here is Flutter Doctor's output:
Flutter version: 1.12.13, Dart version: 2.7, Flutter can't find Android SDK

sdkmanager error:
"Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli"

Best Answer

Open the sdkmanager.bat in a text editor and add echo %CLASSPATH% just below the CLASSPATH=%APP_HOME%\...\sdkmanager-classpath.jar. Then run sdkmanager --help which will echo the CLASSPATH of the required file. And check whether is it the valid path.

In my case, it was the wrong path,

enter image description here

It said my sdkmanger-classpath.jar is in lib folder. But it was not! It was actually inside the lib/_ folder. So as the simple solution what I did was copy the content in side lib/_ folder to lib. Then it worked fine!