Open Java applications fail silently on OS X Maver

2020-02-01 00:15发布

问题:

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

Java and javac all work from the command line.

Opening the apps from the command line gives this error: 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:

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

[Process completed]

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.

回答1:

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.plist and change the key field JVMVersion from 1.6* to 1.7*.

My stack:

  • IntelliJ IDEA 13 CE
  • java version "1.7.0_51"
  • OS X 10.9.1


回答2:

Solution:

Download and install the Java Runtime manually.

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



回答3:

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.

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:

  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:
#!/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 ./studio to it.

  1. Remove the java section in the Info.plist file in the /Applications/Android Studio.app/Contents directory. 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


回答4:

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).

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.

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

/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


回答5:

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.