23

When building my project on android studio, it asks me to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.

When I run "./sdkmanager --licenses", I have the "Could not find or load main class java.se.ee" error.

I found a lot of similar issues on stackoverflow, but non of the solutions provided worked for me.

I already tried: 1- downgrade to java 8

2- export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

3- change sdkmanager file by adding : DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

Mehdi Bouih
  • 231
  • 1
  • 2
  • 5

5 Answers5

53

I had the same issue.
And solved by following the below steps:

1) Install java 8

2) Run command in terminal

unset JAVA_OPTS

3) Then run command in terminal

./sdkmanager --licenses

sommesh
  • 923
  • 9
  • 19
Bhaumik Surani
  • 1,730
  • 3
  • 19
  • 40
19

Well, it's been 4 months since you asked the question. You must have found the answer, but here is a way easy solution for others who are still looking for it:

JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions'

And, Voila the issue is solved!

Why this solved the problem?

Well I don't know the exact reason but, I also don't know why we tend to add java.se.ee through "--add-modules java.se.ee", I tried removing it and error was gone! Maybe because java11 removed EE module, and it was depreciated in java10.

It was just a blind shot which worked!, If anyone knows the proper reason please comment it out!

Khushit Shah
  • 546
  • 6
  • 20
  • 1
    I have upvoted you answer as it was helpful! But can you explain why did this error occurred and what does your solution do? It would be really helpful. – Dhruvam Sharma Sep 17 '19 at 12:15
8

Unsetting JAVA_OPTS worked for me.


 1. unset JAVA_OPTS
 2. sdkmanager --list
 3. sdkmanager "platform-tools" "platforms;android-28"

Hossam Hassan
  • 795
  • 2
  • 13
  • 39
2

Below steps helped me get past above Java error.

JDK Version:

sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: <Choose Java 8>

Procedure:

  1. unset JAVA_OPTS
  2. In folder ~/Android/Sdk/tools/bin$ sudo nano ./sdkmanager
  3. Change line# 31 to

DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions'

  1. Save the file and exit
  2. ./sdkmanager --list

    Installed packages:=====================] 100% Computing updates...
    Path | Version | Description | Location
    ------- | ------- | ------- | -------
    build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2/

2

After struggling to install platform tools from sdk manager with related errors

"Error occurred during initialization of boot layer java.lang.module.FindException: Module java.se.ee not found"

  1. I first downgraded to Java 8 and then set Java 8 as default Java(JDK) How to set or change default Java(JDK):

  2. I tried installing platform tools again.

    sdkmanager "platform-tools" "platforms;android-28"

But then I got the error mentioned above. "Error: Could not find or load main class java.se.ee"

My search brought me here and

unset JAVA_OPTS
sdkmanager "platform-tools" "platforms;android-28"

This was the most closely related problem with a solution I could find and it helped me install platform-tools.

HaydenB
  • 21
  • 3