Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to run sdkmanager --list with Java 9

People also ask

How do I run Sdkmanager?

To open the SDK Manager from Android Studio, click Tools > 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.

How do I fix Sdkmanager not found?

To Solve Android sdkmanager tool not found in Flutter The right solution would be if you have android studio installed then the command flutter doctor and it should now prompt you to run flutter doctor –android-licenses, once you run the license command, accept all licenses by hitting Y and it should solve the problem.

How do I get to Sdkmanager path?

Download the latest "command line tools only" package from the Android Studio downloads page and unzip the package. Move the unzipped cmdline-tools directory into a new directory of your choice, such as android_sdk . This new directory is your Android SDK directory.

What is path to Sdkmanager install commandline tools latest?

It is released concurrently with Android Studio and is installed in the android_sdk /cmdline-tools/ version /bin/ directory. For a complete description of the tools included in this package, see Command line tools in the user guide. To install the latest version, check the SDK Manager for updates.


With the help of this answer, I successfully solved the problem.

We are going to apply a fix in sdkmanager. It is a shell script. It is located at $android_sdk/tools/bin, where $android_sdk is where you unzipped the Android SDK.

  1. Open sdkmanager in your favorite editor.
  2. Locate the line which sets the DEFAULT_JVM_OPTSvariable. In my copy, it is at line 31:

    DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
    
  3. Append the following options to the variable: -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee. Please pay attention to the quotes. In my copy, the line becomes:

    DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
    
  4. Save the file and quit the editor.
  5. Run the command again.

Here is the result:

$ sdkmanager --list
Installed packages:
  Path    | Version | Description              | Location
  ------- | ------- | -------                  | ------- 
  tools   | 26.0.1  | Android SDK Tools 26.0.1 | tools/  

Available Packages:
  Path                              | Version      | Description                      
  -------                           | -------      | -------                          
  add-ons;addon-g..._apis-google-15 | 3            | Google APIs                      
  add-ons;addon-g..._apis-google-16 | 4            | Google APIs                      
  add-ons;addon-g..._apis-google-17 | 4            | Google APIs                      
  add-ons;addon-g..._apis-google-18 | 4            | Google APIs                      
  add-ons;addon-g..._apis-google-19 | 20           | Google APIs                      
  add-ons;addon-g..._apis-google-21 | 1            | Google APIs                      
  add-ons;addon-g..._apis-google-22 | 1            | Google APIs                      
  add-ons;addon-g..._apis-google-23 | 1            | Google APIs                      
  add-ons;addon-g..._apis-google-24 | 1            | Google APIs
...

Hola! It works!

-- Edit: 2017-11-07 --

Please note that you may need to apply the fix above again after running sdkmanager --update, since the sdkmanager shell script may be overridden if the tools package is updated.

Related Answers

  • https://stackoverflow.com/a/43574427/142239
    • @andy-guibert pointed out the necessary options to make this work. He also briefly what those mysterious options mean.

You can set sdkmanager options with SDKMANAGER_OPTS.

Example:

export SDKMANAGER_OPTS="--add-modules java.se.ee"
sdkmanager --list

The accepted answer is outdated as of February 2019. Here's an answer that will work until sdkmanager migrates to a newer version of Java. But by then, you won't have this problem anymore.

OpenJDK 10 was superseeded by OpenJDK 11, which doesn't implement java.se.ee at all. This means that the hack of adding --add-modules java.se.ee doesn't do anything anymore. It also means that OpenJDK 10 will be automatically removed from your system and replaced with OpenJDK 11 the next time you update, if your updates are configured properly.

Modify sdkmanager to use Java 8 by setting JAVA_HOME inside sdkmanager to a Java 8 installation. It's, by default, at ~/Android/Sdk/tools/bin/sdkmanager.

# Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options $
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions'
@rem Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
set JAVA_HOME="C:\ProgramData\scoop\apps\android-studio\current\jre"
set DEFAULT_JVM_OPTS="-Dcom.android.sdklib.toolsdir=%~dp0\.."

This way, you can keep using a sane and maintained version of Java on your system while simultaneously using sdkmanager.

# Java
export JAVA_HOME=/usr/lib/jvm/default-java

And now I've got some pipelines to repair.


When having java 11 in the system, the solutions provided are not valid.

This -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee or--add-modules java.xml.bind do not work with Java 11 on Mac OS.

For that reason you have to downgrade java version to version 8 from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

List Java versions installed

/usr/libexec/java_home -V

Java 11

export JAVA_HOME=$(/usr/libexec/java_home -v 11)

Java 1.8

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Then go to

cd ~/Library/Android/sdk/tools/bin

and

./sdkmanager --licenses

Update 2019-10:

As stated in the issue tracker, Google has been working on a new SDK tools release that runs on current JVMs (9+)!

You can download and use the new Android SDK Command-line Tools inside Android Studio or by manually downloading them from the Google servers:

  • SDK Tools for Linux
  • SDK Tools for Mac OS
  • SDK Tools for Windows

For the latest versions check the URLs inside the repository.xml.

If you manually unpack the command line tools, take care of placing them in a subfolder inside your $ANDROID_HOME (e.g. $ANDROID_HOME/cmdline-tools/...).

Update 2021-03:

The latest stable command-line tools are also available at Googles Downloads-Website


For Windows, if nothing works then try this:

  • Open sdkmanager.bat with Notepad.

  • Locate the following line:

    %JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%

  • Add --add-modules java.xml.bind

The modified line should look like this:

%JAVA_EXE%" %DEFAULT_JVM_OPTS% --add-modules java.xml.bind %JAVA_OPTS% %SDKMANAGER_OPTS%


As some people have mentioned before, this very well could be a simpler problem having to do with one java installation taking precedence over the other.

In my case it was java 8 being overshadowed by a default newer java.

I installed java 8:

sudo apt-get install openjdk-8-jdk

Then I updated the installed java to be the new default:

sudo update-alternatives --config java

Whereby I selected java 8's id number.

After doing these (pretty simple) steps, I could just run sdkmanager without error.

Hope this helps someone!