How to use JRE/JDK v8 with Android Studio v2
I was struggling with a rendering exception in Android Studio v2
1
Failed to load the LayoutLib: com/android/layoutlib/bridge/Bridge : Unsupported major.minor version 52.0
Apparently this can be fixed by telling Android Studio to use JRE v8 (for the IDE, not compiling). One could edit the plist to tell Android Studio to use a different JRE than the default v6, but that’s not recommended by Google.
So here’s a workaround; create a shortcut/alias that exports a value to use JRE v8.
Save this to a .command file, for example LaunchAndroidStudio.command:
1
2
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk
open /Applications/Android\ Studio.app/
Change the icon for the alias. Open the contents of /Applications/Android Studio.app
Navigate to /Contents/Resources
and double click the AndroidStudio.icns, it will open in Preview Copy the icon (Command+C) Open the LaunchAndroidStudio.command by the “Get Info” command. Click the default icon in the top left corner and past the icon (Command+V)