Cannot install sdkmanager in windows 10

TL;DR;

  • copy the content of tools/lib/_ to tools/lib
  • run sdkmanager commands with --sdk_root parameter.

Details

In the line 66 of the sdkmanager.bat, CLASSPATH is defined to be like this

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

and inside the lib directory, sdkmanager-classpath.jar is, oddly, under a subdirectory called -.

I tried to change the path in the batch file but it did not work, so I copied the files from ..../tools/lib/_ to ..../tools/lib and the error disappeard. However, a warning appeared:

Warning: Could not create settings
java.lang.IllegalArgumentException
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

According to this answer, I tried to pass the --sdk_root parameter which worked without problems:

sdkmanager --sdk_root=%ANDROID_HOME% --list
# %ANDROID_HOME% is the environment variable that contains the path of android
# sdk installation. Typically, would be:
# `C:\Users\<USERNAME>\AppData\Local\Android\Sdk\tools`

PS: even I was able to solve this, I would say that this answer is a workaround since the documentation does not mention anything about copying files to other path