The move to Gradle has been for the most part a positive experience for me, except when it comes to IntelliJ on Mac OS. There I ran into a few problems and figured I would share the troubleshooting I took. Fortunately there was a happy ending for me.
The main problem I had was this:
Before we continue much further, you will need to have a few things installed on your machine.
- Java 7 JDK
- Recent ( post April 2014 ) LibGDX nightly
- IntelliJ 13.1 or higher
If you don’t, please install and configure them now. Also make sure to set your JAVA_HOME variable after you install the JDK.
This error occurred when importing the gradle project into IntelliJ as described in this post. Generally the most common cause of this error is a lack of Java 7, which RoboVM requires. It’s important to note, this is the version of Java that IntelliJ needs to run using. You can check the Java version of IntelliJ via the menu IntelliJ IDEA->About IntelliJ IDEA. Like so:
As you can see, I am running JVM 220.127.116.11, but there is a very good chance that you aren’t even if you have it installed. JetBrains currently have this to say on the subject:
At the moment all our products require Apple JDK 1.6 to be installed in order to run on Mac. JDK 1.7 from Oracle is not officially supported yet and has known problems that stop us from using it by default. Oracle JDK 1.7.0_40 has added support for Retina and works much better than previous versions on Mac. You are welcome to give it a try in case you have any problems with Apple JDK.
To force running under JDK 1.7 edit /Applications/<Product>.app/Contents/Info.plist file, change JVMVersion from 1.6* to 1.7*
So, your first step is to enable Java 1.7 ( Java 7 == Java 1.7, Java 6 == Java 1.6 BTW ). If you are unsure how to access the plist file, in Finder open Applications, locate IntelliJ, right click and select Show Package Contents. If you have Xcode install, you can simply double click the pList file. Edit it like so:
Now restart IntelliJ and check the about dialog, you should now be running Java 7.
Still not working? Here are a few quick things to check.
Make sure your JDK is configured correctly. In a terminal window type:
The results should look like:
If you java version is showing as 1.6, but you’ve installed Java 1.7, chances are your JAVA_HOME variable isn’t set correctly.
Next check what gradle sees, change into your project root directory and type:
The results should look like:
Once again, verify that gradle is using the proper JVM. Once again, I believe this value is driven by JAVA_HOME, but I could be wrong.
Finally ( and this was the ultimate problem for me ). Load IntelliJ and make sure there are no Java 1.6 SDKs defined. Warning, this will break any old projects that require Java 6 as this is a global setting.
In IntelliJ with a Project loaded, right click the project and select Open Module Settings
First verify that the project SDK is set to 1.7 and then select SDKs from the side bar.
If a 1.6 SDK exists. Select it the click the – button.
Now try the import again and IntelliJ should work just fine.
If it still doesn’t work, try running gradle from the command line. If you get errors there, it’s not an IntelliJ error. Also, it’s beyond my ability to help you, as troubleshooting Gradle problems is beyond my abilities ( or more accurately desires ).
So if you ran into problems getting RoboVM to work with IntelliJ, hopefully this guide proved of some help.