Could not find or load main class com.android.sdkmanager.Main
Asked Answered
L

10

11

I read these, and these, and these issues about Android SDK installation troubles.

Nothing works for me.

Every time I get the error

C:\Users\user\AppData\Local\Android\android-sdk\tools>android
Error: Could not find or load main class com.android.sdkmanager.Main

when I try to start android.bat.

My environment:

C:\Users\user\AppData\Local\Android\android-sdk\tools>java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

JAVA_HOME=c:\Program Files\Java\jdk1.7.0_71\jre\bin

PATH=c:\Program Files\Java\jdk1.7.0_71\jre\bin\;%SystemRoot%\system32;%SystemRoot%;...

I use latest android SDK version (on Dec 8, 2014) - installer_r23.0.2-windows.exe, tried to use latest JDK7 & JDK8 builds. Same error all the time.

How to fix this?

Loquacious answered 8/12, 2014 at 18:59 Comment(1)
Try to not take the latest build, but some previous stable version instead.Claribelclarice
U
11

Issue:

The JAR required in in the bat file is in path %APP_HOME%\..\lib\sdkmanager-classpath.jar,
but the file was extracted to %APP_HOME%..\lib\_\sdkmanager-classpath.jar, due to an issue in the unzip program used to unzip it.

Solution:

So don't use the Windows' embedded unzip tool. Switch to another, like 7z.
The directory will then be referenced correctly, and you can run sdkmanager.bat without errors.

Unveil answered 23/4, 2020 at 1:47 Comment(2)
Do you have a source link detailing that the the unzip program used is the issue, or why one program causes this issue, while the other does not? RE: "but caused by some unzip issue".Voter
@Voter sorry I didn't find any detail link, only from some old programming experience, windows embed unzip tool will treat file or dir named dot, slash into underscore.Unveil
P
7

A clean way to go about this is to follow the following steps:

  • Go to /path-to-android-sdk/
  • Delete the Tools directory
  • Open Android Studio
  • Open tools -> Sdk Manager
  • Click on the Sdk Tools Tab
  • Uncheck Hide Obsolete Packages
  • Go into the Modal and check Android Sdk Tools (Obsolete)
  • Click Apply
  • Wait While it Downloads....
  • When download is done,go back to /path-to-android-sdk/
  • You should find your tools directory again
  • Everything should work fine now.

Note: What we simply did was delete and replace the old Tools which was corrupted or incompatible

Persuasion answered 31/3, 2020 at 6:21 Comment(1)
I also replaced the command-line tool folder.Provo
F
2

I think the latest version '6200805' has some issue, even I got the same problem.

Solution: Use the older SDK manager version, please find below links for the older version.

Windows no installer: https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip

MacOSX: https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip

Linux: https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip

Foul answered 4/5, 2020 at 3:1 Comment(1)
Hello Rayanni. Could you please provide link to the page containing links to previous versions instead of direct links to files?Oddball
M
0

Look for sdkmanager.jar. This file should be located in the ...tools\lib folder. According to the content of the executed android.bat:

...
set jar_path=lib\sdkmanager.jar;lib\swtmenubar.jar
...

In my case, I also had a /lib_cc folder which contained the missing files. The problem was fixed with backed up the origin /lib file to /lib_1 and copy of /lib_cc to /lib.

Milks answered 23/2, 2020 at 9:47 Comment(0)
S
0

Make sure you have all the required Android SDK packages installed too, these include SDK Platform 25, Android SDK Build-Tools 25.0.2 or later, Android Support Repository, Google Repository and any other SDKs that you may need. OR Try To Reinstall

Sorel answered 23/2, 2020 at 9:53 Comment(0)
T
0

I fixed this by opening sdkmanager.bat file find this line


Change this line

set CLASSPATH=%APP_HOME%\lib\/sdkmanager-classpath.jar


To

set CLASSPATH=%APP_HOME%\lib\_\/sdkmanager-classpath.jar


Thundering answered 27/3, 2020 at 10:42 Comment(0)
A
0

The solution to this is during the initial extraction of .zip file for version '6200805'.

Extract using 7zip or any other extraction tool. The Windows standard "Extract All..." option create a folder with name "-" under the .\tools\lib path and places all jar files there causing the issue.

Hope this helps.

Agrology answered 20/5, 2020 at 3:24 Comment(0)
C
0

I fixed the problem by setting the correct folder hierarchy. which is ANDROID_HOME>cmdline-tools>tools

Copy the tools folder which contain all the files of command line tools into a folder named cmdline-tools. Then it will work.

The tools installed using sdkmanager (eg platform-tools) will be installed in the folder which contains the cmdline-tools folder, in my case ANDROID_HOME folder

Chorion answered 31/5, 2020 at 13:4 Comment(0)
F
0

Downloading the latest SDK fixed it for me - Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli

Forever answered 6/7, 2020 at 13:24 Comment(0)
C
0

On Windows Server 2019, as of commandlinetools-win-6609375_latest.zip we were facing same issue. We placed package inside "Program Files" i.e. "C:\Program Files\Android\cmdline-tools\tools\bin".

It seems this will not work if there is space in path. So we placed it in folder path without spaces i.e. "C:\Android\cmdline-tools\tools\bin" and it is working fine.

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

Craggy answered 4/8, 2020 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.