10339

Can not start androidstudio only in console

Question:

Hi my problem is the next, I downloaded Android Studio and if I go to

<blockquote>

/path/android-studio/bin

</blockquote>

and I execute studio.sh

I get the following error:

No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.

Now if I export JAVA_HOME

export JAVA_HOME=/usr/java/jdk1.7.0_25/

and execute studio.sh Android Studio works but now I create a Symbolic Link to studio.sh

ln -s /path/android-studio/bin/studio.sh /usr/bin/androidstudio

and if I run androidstudio in console this one works, but now I want to create a Gnome launcher

So I did this:

vi /usr/share/AndroidStudio.desktop

and I put the next code into the file:

[Desktop Entry] Name=Android Studio GenericName=IDE para Android X-GNOME-FullName=IDE para Android - Android Studio Comment=Desarrolla aplicaciones para Android Exec= /usr/bin/androidstudio Terminal=false StartupNotify=true Type=Application Icon=/opt/android-studio/bin/idea.png Categories=Development; Name[es_ES]=Android Studio

but at the moment I run AndroidStudio launcher this one gives me the next error:

No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.

I think doing again:

export JAVA_HOME=/usr/java/jdk1.7.0_25/

Will fix the problem but no, the launcher still without working :C Thank's in advance!

<strong>EDIT</strong>

All I did it as su user.

Answer1:

Te contestaré en español porque tu inglés es bastante anemico mano (para los demás, conozco a éste morro)...

¿Que distribución de Linux estás usando? En algunos casos es buena practica instalar el JDK mediante el gestor de paquetes, <a href="http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/" rel="nofollow">por ejemplo para Fedora</a>, y posteriormente modificar las alternativas, eso depende de tus necesidades de contar con diferentes opciones de JDK (Oracle, OpenJDK, etc. y sus correspondientes versiones).

En Ubuntu puedes revisar <a href="http://manpages.ubuntu.com/manpages/raring/es/man8/update-alternatives.8.html" rel="nofollow">Ubuntu manpage</a> para mayor información de update-alternatives.

Adicionalmente, tienes que agregar a tu PATH la referencia a la carpeta bin/ de tu JDK definida en el export JAVA_HOME=/donde/tengas/tu/jdk, así como a tu CLASSPATH la referencia a tu carpeta lib/es decir:

export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=$JAVA_HOME/lib

Nota: Otra cosa que tienes que observar es que en los export es una buena práctica no colocar el último slash (observa los dos exports que acabo de agregar, si tuvieran ese último slash en el primero se vería algo así en tu PATH : .../donde/tengas/tu/jdk//bin... not cool, bro! ¬¬)

Te recomendaría que adicionalmente a modificar las alternativas (en el caso de ser necesario en tu distro), utilices un enlace simbólico para cualquier JDK que no instales mediante el gestor de paquetes y así tener mayor flexibilidad, por ejemplo:

lrwxrwxrwx 1 root root 10 jul 16 19:01 java -> oracle-jdk-7 drwxr-xr-x 8 root root 4096 nov 14 2012 jdk1.6.0_25 drwxr-xr-x 8 root root 4096 nov 14 2012 jdk1.6.0_37 drwxr-xr-x 8 root root 4096 feb 15 15:21 jdk1.7.0_15 drwxr-xr-x 8 root root 4096 jun 5 23:07 jdk1.7.0_25 lrwxrwxrwx 1 root root 11 jul 16 19:00 oracle-jdk-6 -> jdk1.6.0_37 lrwxrwxrwx 1 root root 11 jul 16 19:00 oracle-jdk-7 -> jdk1.7.0_25

y al verificar la versión del JDK se observa:

[root@rojas opt]# java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

en el caso de necesitar modificar la alternativa, harías referencia a la ruta /ruta/completa/enlace/simbolico/java y con solo cambiar dicho enlace cambiarías de JDK.

Si esto no te parece muy buena opción, pues tendrías que agregar todas esas versiones a las alternativas (y cada que descargues una nueva, repetir el proceso)... es cosa de que veas que te resulta más cómodo.

Una vez que terminaste de hacer esos exports, ¿ejecutaste el comando source?

source /path/a/archivo/donde/tienes/todos/esos/exports

yo, personalmente, agrego todos esos export en /etc/profile

Ejecutar el Android-Studio como root me parece demasiado hardcore, pero bueno.

Answer2:

In my case, even though I had configured JDK_HOME and JAVA_HOME, Android studio would not start.<br /> The problem turned out to be that we don't need to have to sudo a program t make it work. I had installed Android Studio into /usr/local and did sudo ./studio.sh to start it but it complained it couldn't find the JAVA_HOME and JDK_HOME variables. But when I installed it into my home folder, it worked without any problem by directly running ./studio.sh.

The problem for a new user might be about realizing that most copy, move andrm operations in /usr/local result in needing to use sudo, and so a person might use sudo ./studio when in usr/local, which is unnecessary and the system searches for the root user's configuration of JAVA_HOME and JDK_HOME which it does not find.

Answer3:

Open studio.sh and after the lines:

MKTEMP=`which mktemp` RM=`which rm` CAT=`which cat` TR=`which tr`

add

JAVA_HOME=/usr/java/latest

And that's it!

Recommend

  • Posting comment with ajax and jquery
  • JavaScript onDeviceReady not firing
  • Get storage account of Azure VM
  • a:first-child modifying all links within my list
  • How to build PHP application with multiple language support (English, French, Chinese etc..)
  • SQL Alchemy overriding ==
  • Apache doesn't execute script of index.php in root automatically
  • :hover CSS is not working?
  • curl not working for getting a web page content, why?
  • How to forcefully download .csv file instead of getting in open on browser in html
  • finding symmetric difference/unique elements in multiple arrays in javascript
  • Matrix problem Python
  • hibernate.properties does not found in maven project using hibernate
  • K Shortest Path Python Not Working
  • Simple script doesn't show anything on the Output in LuaEdit
  • Grouping vars in function
  • how to use chinese address get geocoding by ggmap
  • Changing the WPF DatePicker Year/Month header area background color
  • What does the “?” mean in the following statement
  • Alternative to XInclude
  • Duplicated password validation messages ONLY IF new password is 1 char long
  • Click button with javascript
  • eC (Ecere) how to not worry about private data fields of a class
  • What components I need to create VS 2017 offline layout for UWP development?
  • How do I know what reference to include to import a specific .NET namespace?
  • Error Installing Windows 10 development tools for Visual Studio 2015 RC on Windows 8.1
  • Hibernate - Cannot connect to DB
  • why fullscreen functionality is not working in chrome?
  • How can I make a 100% stacked chart with nvd3?
  • Launch powershell script from UWP app with FullTrustProcessLauncher class
  • jinja2 template not found and internal server error
  • iOS 6 dateFromString returns wrong date
  • Create a link to a web page that runs a Javascript function on the page
  • iOS Cordova first plugin - plugin.xml to inject a feature
  • Compress a file with GZipStream while maintaining its meta-data
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • How can I include If-None-Match header in HttpRequestMessage
  • Parse a date string in a specific locale (not timezone!)
  • Display issues when we change from one jquery mobile page to another in firefox
  • Do I've to free mysql result after storing it?