I am using Kali Linux at the moment. The following command printenv _JAVA_OPTIONS
works, but only temporarily. If you are interested in knowing why? Visit site link. Once you restart android studio the error pops up again.
Here's my workaround:
- Open your bash terminal.
- Unset the variable;
printenv _JAVA_OPTIONS
- Switch your current directory to that of your android studio launcher, usually in;
android-studio/bin
- Then launch your android studio;
./studio
Here's an elaborate example:

In my case, the error didn't pop up. The process seems tedious for every android studio launch but at least it works. I hope my answer helps the next victim.
The following script should make work easier. Just remember to make it executable by;
chmod +x <file_name.py>
- The script:
#!/usr/bin/env python3
"""Script to counteract _JAVA_OPTIONS error in android studio"""
import subprocess
import os
def studio_launcher():
"""android-studio launcher"""
# change dir to android-studio dir
os.chdir('/opt/android-studio/bin')
# execute launch
subprocess.Popen(['./studio.sh'])
me_status_code = os.system("printenv _JAVA_OPTIONS")
#If printenv is successful
if me_status_code == 0:
print("We in")
try:
print("Try to unset")
del os.environ["_JAVA_OPTIONS"]
print("Unset successful")
studio_launcher()
except SystemError:
print("Sth went wrong!!!")
studio_launcher()
else:
print("Var empty!!")
print(me_status_code)
studio_launcher()