Useful IntelliJ IDEA Settings

I switched from Eclipse to IntelliJ IDEA a while ago because it kinda was way easier to get the programming environment at work up and running with IntelliJ. And because I use it at work and don’t want to do the switch every time i start programming at home I decided to switch to IntelliJ here aswell.

Up until now I really got to like this fancy IDE from Jetbrains but there still were some annoyances I had to fix. The following section covers a few settings I’d like to mention because it makes my programming life a little easier :D

Allow placement of caret after end of line

When I click on a line I usually expect the caret to jump right to the ending of the line. Not so in IntelliJ. The caret keeps blinking exactly there where you clicked so I always had to press [END] to quickly move to caret behind the last character of the line. If you feel like disabling this behaviour you can do it as follows:

  • Go to “File > Settings” or press “[Ctrl] + [Alt] + [S]“
  • In the search dialog at the top left type “caret”
  • Select the entry “Editor” (if not yet selected)
  • Uncheck the setting “Allow placement of caret after end of line” and click OK

Highlight usages of element at caret

Another really handy feature which I know from Eclipse and was missing is the highlighting of all the element usages of the element your currently pointing at with the caret. To enable this do the following:

  • Go to “File > Settings” or press “[Ctrl] + [Alt] + [S]“
  • In the search dialog at the top left type “caret”
  • Select the entry “Editor” (if not yet selected”)
  • Check the setting “Highlight usages of element at caret” and click OK

These 2 convenience settings just made your life so much easier ;)

I take further setting recommendations in the comments :D I’m thinking of adding some nice to know keyboard shortcuts to this article. I guess this article will be updated.

Sharing LibGDX assets

I recently came across the problem of not being able to properly share the “data” folder of my Desktop and Android LibGDX project in IntelliJ IDEA. Now i found 3 solutions for this. Each one has it’s benefits.

Solution 1 using only IntelliJ IDEA

In this solution both projects use the “data” folder in your Desktop project:

  • Right-click you Android project and select “Open Module Settings [F4]“
  • Under “Modules” select the Android Facet
  • In the tab “Structure” you can change the default Android assets directory
  • Browse to the folder containing the data folder of your Desktop project an click OK

Notice: You have to select the parent folder of the data folder in your Desktop project since the Android project will look for the data folder inside the defined assets folder.

The first solution didn’t work for me though, because I’m working on a project with a mate and he is using Eclipse with the default LibGDX project setup explained here.

Now, if you want to keep the two separate data folders but also keep their files automatically in sync, there’s an elegant way to do this using Ant.

Solution 2 using Ant

In this solution both projects keep their own “data” folder but their files are automatically synced right before the project is run with the help of a small Ant task.

  • Right-click your Android project and select “New > File”
  • Name it “build.xml”
  • Paste the following content into the newly created “build.xml”
<project name="Your Project Name here" basedir="." default="refreshAssets">
  <property name="from.dir"  value="../glowjump_java/data"/>
  <property name="to.dir"     value="./assets/data"/>

  <target name="refreshAssets">
    <copy todir="${to.dir}">
      <fileset dir="${from.dir}"/>
    </copy>
  </target>
</project>
  • Now go to “Run > Edit Configurations…”
  • Select your Android Run Configuration and check “Run Ant target” at the bottom
  • Click on “…” and select the newly created Ant task called “refreshAssets”

This task is now executed every time you launch the Android application. Meaning that the files in the data folder are copied from the Desktop project to the Android project right before launch.

For more info about the copy command in Ant see here.

Solution 3 using a symlink (Windows)

The third and probably easiest solution is to create a Windows symlink called “data” inside the Android “assets” folder. This symlink will point to the “data” folder of your Desktop project.

  • In your FileExplorer navigate inside your LibGDX Android project folder
  • Right-click the “assets” folder and select “Open command window here”
  • In the command prompt enter mklink /D data "..\..\your_libgdx_desktop_project_folder_name\data
  • On success the following message should be displayed symbolic link created for data <<===>> ..\..\your_libgdx_desktop_project_folder_name\data
  • Refresh the project view in IntelliJ IDEA
  • You should now see the data symlink as a normal folder containing the files of your desktop project

Please feel free to ask questions in the comments!

Android SDK Tools update fails

If the update of your Android SDK Tools fails, because a folder could not be moved, try this solution:

  1. Create a copy of your “tools” folder under your “Android/android-sdk” folder
  2. Go into that copied folder and run the file “android.bat”
  3. The Android SDK Manager will start and allow you to update whatever you want to without errors
  4. After the update you can close the SDK Manager and delete the copied “tools” folder

DailyConnect

My bachelor thesis, DailyConnect, is a hitch a ride platform available for Android and iOS smart phones.

We worked on the server, an Android and iOS client as a group of 6. 2 people for each task. My task was to create the Android client app with my work mate and all the graphics we needed for the Android and iOS app.