Open Java applications fail silently on OS X Mavericks

五迷三道 提交于 2019-11-27 22:50:28

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

Solution:

Download and install the Java Runtime manually.

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

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!