Linux ./studio.sh 之后的 Android Studio 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17033726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:11:16  来源:igfitidea点击:

Android Studio error after ./studio.sh

linuxandroid-studio

提问by Bryan Villafa?e

After ./studio.shin a terminal I get this error "tools.jar is not in android studio classpath Please ensure JAVA_HOMEpoints to JDK rather than JRE".

./studio.sh终端中后,我收到此错误“tools.jar 不在 android studio 类路径中,请确保JAVA_HOME指向 JDK 而不是 JRE”。

I Google it and this is what everybody says: "you need to set your environment variable to JDK path instead of JRE"

我谷歌一下,这就是每个人所说的:“你需要将环境变量设置为 JDK 路径而不是 JRE”

I try this two commands

我试试这两个命令

export PATH=${JDK_HOME}:/etc/java-7-openjdk

export PATH=${JAVA_HOME}:/etc/java-7-openjdk

And execute again ./studio.shand I get the same error

再次执行./studio.sh,我得到同样的错误

My OS is Linux Mint 14

我的操作系统是 Linux Mint 14

采纳答案by user2533809

I solved the problem combining Jerome's and Jarod's answer:

我结合 Jerome 和 Jarod 的回答解决了这个问题:

  1. Install JDK -- sudo apt-get install openjdk-7-jdk
  2. Environment Variable -- sudo nano /etc/environmentadding the following line:
  3. JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
  4. Reboot, and Android Studio starts up. (I had added also a link to studio.sh to the main menu).
  1. 安装JDK—— sudo apt-get install openjdk-7-jdk
  2. 环境变量——sudo nano /etc/environment添加以下行:
  3. JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
  4. 重启,Android Studio 启动。(我还在主菜单中添加了一个指向 studio.sh 的链接)。

Also I just found https://stackoverflow.com/a/17827697/2533809which seems to have a nice write-up, pretty much the same answer.

此外,我刚刚发现https://stackoverflow.com/a/17827697/2533809似乎写得很好,答案几乎相同。

(I'm using Debian 7 Wheezy)

(我正在使用 Debian 7 Wheezy)

回答by Jarod

for openjdk: export JAVA_HOME=/usr/lib/jvm/default-java

对于 openjdk:导出 JAVA_HOME=/usr/lib/jvm/default-java

but you would better use the oracle jre to run android studio

但是你最好使用oracle jre来运行android studio

回答by Jerome

I have figured it out. You need to install openjdk-jdk. Opensjdk-jre is not enough. So in terminal all you need to do is write sudo apt-get install openjdk-7-jdkthen press yes. Open the android studio bin folder, double click on studio.sh, open in terminal, press enter, and then android studio should work.

我已经想通了。你需要安装openjdk-jdk。Opensjdk-jre 是不够的。所以在终端你需要做的就是写sudo apt-get install openjdk-7-jdk然后按是。打开android studio bin文件夹,双击studio.sh,在终端打开,回车,然后android studio就可以工作了。

回答by Milan Kerslager

This seems like permission problem. Someone who packed Android Studio, has the original files under non-root account. If you unpack it as root, the files and dirs has no permission for "other" (just for owner). The person who is packing Android Studio knows a lot about Android and Java, but not much about Unix permissions (uch!). There are two possible solutions:

这似乎是权限问题。打包Android Studio的人,在非root帐户下拥有原始文件。如果您以 root 身份将其解压缩,则文件和目录没有“其他”权限(仅适用于所有者)。打包 Android Studio 的人对 Android 和 Java 了解很多,但对 Unix 权限知之甚少(哎哟!)。有两种可能的解决方案:

a) unpack android-studio-bundle-...-linux.tgz as normal user, not as root (this has an advantage - you will be able to update Andriod Studio by clicking menu; but this is generally stupid because you are open to malware attack)

a) 以普通用户而非 root 身份解压 android-studio-bundle-...-linux.tgz(这有一个优势 - 您可以通过单击菜单来更新 Andriod Studio;但这通常很愚蠢,因为您处于打开状态恶意软件攻击)

b) fix read permissions for files and dirs for whole android-studio directory with something like: chmod -R +r /opt/android-studio

b) 修复整个 android-studio 目录的文件和目录的读取权限,例如:chmod -R +r /opt/android-studio

回答by Kesavan Muthuvel

Here's how I solved the same problem in my system: Thanks for @user2533809

以下是我在系统中解决相同问题的方法:感谢@user2533809

$sudo apt-get install openjdk-7-jdk
$ls /usr/lib/jvm/java-1.7.0-openjdk-i386
ASSEMBLY_EXCEPTION  bin  docs  include  jre  lib  man  THIRD_PARTY_README
$export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
$./studio.sh 

Environment :

环境 :

kesavan@kesavan-Ideapad-Z460:bin$ uname -a
Linux kesavan-Ideapad-Z460 3.2.0-59-generic-pae #0trisquel1 SMP Sat Feb 22 03:55:17 UTC 2014 i686 i686 i386 GNU/Linux
kesavan@kesavan-Ideapad-Z460:bin$ 

回答by pablopatarca

You must be sure that your jre and jdk works fine.

您必须确保您的 jre 和 jdk 工作正常。

Run

$ sudo apt-get install default-jre

and then...

进而...

$ sudo apt-get install default-jdk

to make sure you have your javac path run

确保您运行了 javac 路径

$ whereis javac

It should return something like this:

它应该返回如下内容:

javac: /usr/bin/javac /usr/bin/X11/javac /usr/share/man/man1/javac.1.gz

If it does not work, you can try change the JAVA_HOME in /etc/enviroment file

如果它不起作用,您可以尝试更改 /etc/enviroment 文件中的 JAVA_HOME

Append JAVA_HOME="${/.../JVM_PATH}"

附加 JAVA_HOME="${/.../JVM_PATH}"

For example:

例如:

JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"

and then reload this file:

然后重新加载这个文件:

$ source /etc/environment

Source: link

来源:链接

回答by David

Although I have JDK installed and was pointing to it, i didn't have java-1.7.0-openjdk-develinstalled (Fedora).

虽然我已经安装了 JDK 并指向它,但我没有安装 java-1.7.0-openjdk- devel(Fedora)。

回答by EliT

I solved this by installing the jdk. This sounds annoyingly simple but I missed it. I thought I Had installed the jdk, but I had actually installed the jre.

我通过安装 jdk 解决了这个问题。这听起来很简单,但我错过了。我以为我已经安装了jdk,但实际上我已经安装了jre。

Wrong:

错误的:

sudo apt-get install openjdk-7-jre

Right:

对:

sudo apt-get install openjdk-7-jdk

As soon as I did that, it started up fine for me. The things we miss sometimes....

一旦我这样做了,它对我来说就开始好了。我们有时会想念的东西......

回答by Caribe95

This is what I did to solve the problem:

这是我为解决问题所做的工作:

cd /opt/ (where android-studio directory is located)

cd /opt/(android-studio目录所在)

sudo chown -R your_user:your_user android-studio

须藤 chown -R your_user:your_user android-studio

(where your_useris... yes your username :) )

(其中your_user是......是你的用户名:))

回答by Ayoub Foussoul

the solution for me was to modify studio.sh and add JAVA_HOME as a variable:

我的解决方案是修改 studio.sh 并添加 JAVA_HOME 作为变量:

# ---------------------------------------------------------------------
# Locate a JDK installation directory which will be used to run the IDE.
# Try (in order): STUDIO_JDK, ../jre, JDK_HOME, JAVA_HOME, "java" in PATH.
# -------------------------------------------------------------------

     JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-i386/

if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then (etc..)