打开 Java 应用程序在 OS X Mavericks 上静默失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19594627/
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-12 18:37:36  来源:igfitidea点击:

Open Java applications fail silently on OS X Mavericks

javaintellij-ideaandroid-studioosx-mavericks

提问by Sveinung Kval Bakken

When opening Intelli J or Android Studio after the Mavericks update nothing happens, fails silently.

在 Mavericks 更新后打开 Intelli J 或 Android Studio 时没有任何反应,默默地失败。

Java and javac all work from the command line.

Java 和 javac 都在命令行中工作。

Opening the apps from the command line gives this error: LSOpenURLsWithRole() failed with error -10658 for the file /Applications/Android Studio.app.

从命令行打开应用程序会出现以下错误: LSOpenURLsWithRole() failed with error -10658 for the file /Applications/Android Studio.app.

Opening Intelli J's idea_appLauncher(/Applications/...app/Contents/MacOS/idea_appLauncher) from the command line gave away some more information:

idea_appLauncher从命令行打开 Intelli J's (/Applications/...app/Contents/MacOS/idea_appLauncher) 提供了更多信息:

someuser@machine:~$ /Applications/IntelliJ\ IDEA\ 12\ CE.app/Contents/MacOS/idea_appLauncher ; exit; No Java runtime present, requesting install. logout

[Process completed]

someuser@machine:~$ /Applications/IntelliJ\ IDEA\ 12\ CE.app/Contents/MacOS/idea_appLauncher ; 出口; 不存在 Java 运行时,请求安装。登出

[过程完成]

Obviosuly Mavericks is not picking up on my Java installation even if it's part of PATH and JAVA_HOME is set and it's not giving the "Please install Java runtime" prompt.

Obviosuly Mavericks 没有接受我的 Java 安装,即使它是 PATH 的一部分并且设置了 JAVA_HOME 并且它没有给出“请安装 Java 运行时”提示。

采纳答案by Sveinung Kval Bakken

Solution:

解决方案:

Download and install the Java Runtimemanually.

手动下载并安装Java 运行时

You also need to enable application from all sources from Settings/Security & Privacy.

您还需要从设置/安全和隐私中的所有来源启用应用程序。

回答by Timu?in

In my case, I saw an "Allow it anyway"option for Android Studio under Settings->Security&Privacy->General Tab. When I click it, it removed the restriction for Android Studio.

就我而言,我"Allow it anyway"Settings->Security&Privacy->General Tab. 当我点击它时,它取消了对 Android Studio 的限制。

回答by Shawn

This is due to android studio/intellij is still using the old "JavaLaunching" framework which has deprecated with Java 7. Either you install an End-Of-Life version of JDK 6, or request Android Studio to upgrade to use oracle's JDK appbundle.

这是因为 android studio/intellij 仍在使用旧的“JavaLaunching”框架,该框架已被 Java 7 弃用。要么安装 JDK 6 的生命周期终止版本,要么请求 Android Studio 升级以使用 oracle 的 JDK appbundle。

I really hate to install a JAVA 6 so I'll have two JDKs on my machine. so I hacked the Android studio files such that they can be launched from the dock:

我真的很讨厌安装 JAVA 6,所以我的机器上会有两个 JDK。所以我破解了 Android Studio 文件,以便它们可以从 Dock 启动:

  1. Change the studio (in /Applications/Android Studio.app/Contents/MacOS) file from a JavaLauncher stub to a shell script, here's how it look like:
  1. 将 studio (in /Applications/Android Studio.app/Contents/MacOS) 文件从 JavaLauncher 存根更改为 shell 脚本,如下所示:
#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home`
echo JAVA_HOME=$JAVA_HOME
export APP_PACKAGE='/Applications/Android Studio.app'
exec $JAVA_HOME/bin/java -cp $JAVA_HOME/lib/tools.jar:"$APP_PACKAGE"/lib/bootstrap.jar:"$APP_PACKAGE"/lib/extensions.jar:"$APP_PACKAGE"/lib/util.jar:"$APP_PACKAGE"/lib/jdom.jar:"$APP_PACKAGE"/lib/log4j.jar:"$APP_PACKAGE"/lib/trove4j.jar:"$APP_PACKAGE"/lib/jna.jar -Didea.platform.prefix=AndroidStudio -Didea.paths.selector=AndroidStudioPreview -Dfile.encoding=UTF-8 -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Xbootclasspath/a:"$APP_PACKAGE"/lib/boot.jar -XX:MaxPermSize=256m -Xdock:icon="$APP_PACKAGE"/Contents/Resources/AndroidStudio.icns com.intellij.idea.Main

make sure to chmod +x ./studioto it.

确保chmod +x ./studio这样做。

  1. Remove the java section in the Info.plist file in the /Applications/Android Studio.app/Contentsdirectory. Otherwise, Apple will still ask you to install JDK 6: edit the file and remove the whole java section. The diff will look like: http://pastebin.com/QS8M45cr
  1. 删除/Applications/Android Studio.app/Contents目录中Info.plist文件中的java部分。否则,Apple 仍会要求您安装 JDK 6:编辑文件并删除整个 java 部分。差异将如下所示:http: //pastebin.com/QS8M45cr

回答by juanmirocks

In my case I saw a similar error but with different error code:

就我而言,我看到了类似的错误,但错误代码不同:

LSOpenURLsWithRole() failed for the application /Applications/IntelliJ IDEA 13 CE.app with error -10810.

This worked for me:just edit the file /Applications/IntelliJ\ IDEA\ 13\ CE.app/Contents/Info.plistand change the key field JVMVersionfrom 1.6*to 1.7*.

这个工作对我来说:刚才编辑的文件/Applications/IntelliJ\ IDEA\ 13\ CE.app/Contents/Info.plist和关键领域发生变化JVMVersion,从1.6*1.7*

My stack:

我的堆栈:

  • IntelliJ IDEA 13 CE
  • java version "1.7.0_51"
  • OS X 10.9.1
  • IntelliJ IDEA 13 CE
  • java版本“1.7.0_51”
  • OS X 10.9.1

回答by VonSchnauzer

I had java 1.7 but none of the above worked or matched my problem log. Starting Android Studio silently failed. I reverted to java 1.6, same behaviour and both had the same error log (see below).

我有 java 1.7,但以上都没有工作或匹配我的问题日志。静默启动 Android Studio 失败。我恢复到 java 1.6,相同的行为并且都有相同的错误日志(见下文)。

My error log showed:

我的错误日志显示:

android studio taskgated failed to get signing info for  (cannot make code: invalid signature (code or signature have been modified))

Most answers on StackOverflow to that particular error log is that you have to "Allow applications downloaded from anywhere" in Security & Privacy.

StackOverflow 上对该特定错误日志的大多数答案是,您必须在安全和隐私中“允许从任何地方下载应用程序”。

Then I saw what @jmcejuela did and that worked quite well and I edited

然后我看到@jmcejuela 做了什么,效果很好,我编辑了

/Applications/Android\ Studio.app/Contents/Info.plist 

and changed

并改变了

1.6*

to

1.7*

My environment:

我的环境:

  • Android Studio 0.4.2
  • java version "1.7.0_45"
  • OSX Version 10.8.5
  • 安卓工作室 0.4.2
  • java版本“1.7.0_45”
  • OSX 版本 10.8.5