Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"

like image 239
Amer Alahmar Avatar asked Mar 17 '20 17:03

Amer Alahmar


1 Answers

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!

like image 96
Tharindu Sathischandra Avatar answered Sep 21 '22 13:09

Tharindu Sathischandra