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

此生再无相见时 提交于 2020-05-14 19:10:10

问题


I read all this crap 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?


回答1:


Issue:

JAR required in bat file is in path %APP_HOME%\..\lib\sdkmanager-classpath.jar but caused by some unzip program issue, this file was extracted to %APP_HOME%..\lib\_\sdkmanager-classpath.jar

Solution:

So don't use windows embed unzip tool, switch to others like 7z, the directory will be correctly, and you can run sdkmanager.bat with no error.




回答2:


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




回答3:


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




回答4:


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.




回答5:


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




回答6:


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




来源:https://stackoverflow.com/questions/27364963/could-not-find-or-load-main-class-com-android-sdkmanager-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!