Search code examples
javaandroid-studiointellij-ideapreview

Android Studio won't start, libjli.dylib too short


Cannot open Android Studio 3.0 Preview, I have Android Studio 2.3 running in the same machine, Java 1.6 AND Java 1.8 installed, JAVA_HOME configured to the 1.8 version. Still this new Android Studio version doesn't open.

Trying to open it directly from the studio file, I got the following error:

allVms required 1.8*,1.8+
Cannot load JVM bundle: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib): no suitable image found.  Did find:
        /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib: file too short
        /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib: file too short" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib, NSDebugDescription=dlopen_preflight(/Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib): no suitable image found.  Did find:
        /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib: file too short
        /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib: file too short, NSBundlePath=/Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk, NSLocalizedDescription=The bundle “OpenJDK 8” couldn’t be loaded because it is damaged or missing necessary resources.}

Taking closer attention to this line:

libjli.dylib: file too short, NSBundlePath=/Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk, NSLocalizedDescription=The bundle “OpenJDK 8” couldn’t be loaded because it is damaged or missing necessary resources.}

I tried find some problem with the bundled JDK, looks good, the archive downloaded has no issues. Anyone ever had something like that?


Solution

  • I was about to post the issue when I found the problem.

    For me the issue was that libjli.dylib file in MacOS folder, it's not a file, but a symbolic link to the real file, but when I decompressed it, it lost its properties as a symbolic link, and became an empty file. Deleting the following file, and creating a new symbolic link solved the issue.

    /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib
    

    this ^ guy links to this:

    /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/Home/jre/lib/jli/libjli.dylib
    

    Given that your Android Studio app location is /Applications/Android Studio 3.0 Preview.app as mine, the following commands solved the issue for me:

    First remove:

    rm /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib
    

    Then create a new link:

    ln -s /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/jre/jdk/Contents/Home/jre/lib/jli/libjli.dylib /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/jre/jdk/Contents/MacOS/libjli.dylib
    

    Just open Android Studio as usual.