Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 396
tmporaries Avatar asked Dec 08 '14 18:12

tmporaries


People also ask

How do I fix Sdkmanager not found?

You need to open Android Studio then go to Tools > SDK Manager > SDK Tools tab, uncheck the option Hide Obsolete Packages. And install Android SDK Tools and Android SDK Command-line Tools.

How do I find my Sdkmanager?

To open the SDK Manager from Android Studio, click Tools > Android > SDK Manager or click SDK Manager in the toolbar. If you're not using Android Studio, you can download tools using the sdkmanager command-line tool.

Could not find or load main class Android Studio?

The "Could not find or load main class" error occurs when the JVM fails to load the main class. This can happen due to various reasons, such as: The class being declared in the incorrect package. The file path of the class not matching the fully qualified name.

How do I open SDK manager in terminal?

From Eclipse (with ADT), select Window > Android SDK Manager. On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory. On Mac or Linux, open a terminal and navigate to the tools/ directory in the Android SDK, then execute android sdk .


2 Answers

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.

like image 177
Francis.TM Avatar answered Sep 28 '22 13:09

Francis.TM


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

like image 20
Rayanni Kranti Avatar answered Sep 28 '22 12:09

Rayanni Kranti