Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Device Monitor not found JDK Path

I'm using Arch Linux with Gnome.

I open Android Studio by the desktop item. The code editor works fine, the device manager starts correctly and the app run like a charm, but when I try to open the Device Monitor, I get this error:

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Monitor. No Java virtual machine was found after searching the following locations: /home/grams/Android/Sdk/tools/lib/monitor-x86_64/jre/bin/java java in your current PATH When i run the android studion from command line, the Device Monitor works.

Here is the .desktop content

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/home/grams/android-studio/bin/studio.png
Name[en_US]=Android Studio
Exec=/home/grams/android-studio/bin/studio.sh
Comment[en_US]=Android Studio IDE
Name=Android Studio
Comment=Android Studio IDE
Icon=/home/grams/android-studio/bin/studio.png

My JRE and JDK variables are being added on /etc/profile. When i run Android Studio on the command line, this error not occurs. Maybe it is a problem with Gnome launcher ?

like image 317
Juliano Grams Avatar asked Jun 30 '16 03:06

Juliano Grams


3 Answers

Please add the location of the folder containing javaw.exe to the System PATH Environment Variable: e.g PATH = "C:\Program Files\Java\jdk1.8.0_112\bin"

like image 116
Spoon Avatar answered Sep 21 '22 04:09

Spoon


Newest Android Studio Bundle comes with its own JRE (under <ANDROID_STUDIO>/jre and this is the recommended JRE to work with (look at File / Project Structure / SDK Location).

Likewise, a simple option is to create a symbolic link under the monitor tools to keep JRE in line with Android Studio even getting an update.

For MAC or Linux:

#ln -s <ANDROID_STUDIO>/jre <SDK>/tools/lib/monitor-x86_64/jre

32 bits:

#ln -s <ANDROID_STUDIO>/jre <SDK>/tools/lib/monitor-x86/jre

Then the ddms monitor works for both ways: from Studio IDE (Tools / Android / ADM) or command line (<SDK>tools/./monitor)

like image 42
user1998382 Avatar answered Sep 20 '22 04:09

user1998382


Define your environment variables in the initialization file for your login shell: most likely .profile or .bash_profile, depending on your setup. Something like:

export JAVA_HOME="/usr/lib/jdk1.8.0_05"
export PATH=$PATH:$JAVA_HOME

Read more at: where should i manually install JDK8? and JDK installation on Archlinux

like image 44
ישו אוהב אותך Avatar answered Sep 20 '22 04:09

ישו אוהב אותך