Skip to content

Intellij

This is the main IDE used for android programming now, and you won't get far without it i'm afraid.

Note

Intellij opens a windows per projects, so don't search for the projects tree.

Installation

The first thing to notice is that intellij fails to notice the JAVA_HOME variable, and you have to install that by hand. And it also set's the java version to 1.3 so we change that as well.

problem

Some messages pointing to that :

Warning:java: source value 1.3 is obsolete and will be removed in a future release

!!! error "Error:(208, 2) java: annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations)"

fix

  • File -> Project Structure
  • Platform Settings -> JDK home path : browse your jdk installation
  • Project Settings -> Projects SDK -> set it to the one installed, in my case 1.8
  • Projects Settings -> Project Language level -> this is set to 1.3, match it with your sdk (8)

These are project settings so i fear you will have to do that for each project ;(

import gradle projects

When importing a build.gradle file, intellij asks for the Gradle Home directory. On OSX when installed with brew it is something like :

osx
/usr/local/Cellar/gradle/x.x/libexec

But here is a quick script that helps. For some reason it failed in my home directory, so maybe do it in an empty directory: Create a build.gradle file containing this :

build.gradle
1
2
3
task getHomeDir << {
    println gradle.gradleHomeDir
}

Now run it with :

run
gradle getHomeDir

and it will dump some warnings but also the value you want :

output
1
2
3
4
5
6
7
8
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_65tlzu6j75xbuxlden3qqn242.run(/Users/keesklop/effe/effe/build.gradle:1)
:getHomeDir
/usr/local/Cellar/gradle/3.3/libexec

BUILD SUCCESSFUL

Total time: 0.712 secs

And still it does not work, but i'm fed up with intellij for a while again...

ideavim

You will have to install a plugin though. Go to :

"Intellij Idea" -> "Preferences" -> "Plugins" -> "Install jetbrains plugin"

Then choose ideavim and press install, a restart of intellij will be needed.

Note that ctrl-N and ctrl-P do not work, they are assigned to other mappings. Here is the instruction that worked. BOTH These are needed :

Could not get CTRL-N and CTRL-P to work after mapping them to "Cyclic Expand Word" and "Cyclic Expand Word (Backward)" in IDEA 2016.2.5 (while running IdeaVIM). Both keystrokes just did nothing. (settings -> keymap , type 'cyclic' in the search window)

The solution was to select "Settings" from the File Menu, then "Other Settings" -> "Vim Emulation", and set the "Handler" for Ctrl+N and Ctrl+P to "IDE" instead of "Vim".

keyboard hang and setting env vars in launcher

I don't want to accuse ideavim, but sometimes the keyboard completely hangs in intellij. You can get the control back with the following command in another xterm:

keyboard freeze
ibus-daemon -rd

To get rid of it altogether (but you lose national characters), set this before the command with which you start idea :

sync mode
IBUS_ENABLE_SYNC_MODE=1 

However, this would become a line like this in the launcher entry for idea (by the way it will end up in (/home/kees/.config/mate/panel2.d/default/launchers//idea.sh.desktop)

desktop ini
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/home/kees/Install/idea-IC-172.4574.11/bin/idea.png
Exec=IBUS_ENABLE_SYNC_MODE=1 /home/kees/Install/android-studio/bin/studio.sh
Name[en_US]=idea
Name=idea
Icon=/home/kees/Install/idea-IC-172.4574.11/bin/idea.png

Exec=IBUS_ENABLE_SYNC_MODE=1 /home/kees/Install/android-studio/bin/studio.sh

Two time = = will cause the command to never even start. You need to use env in front of it to work:

startup
Exec=env IBUS_ENABLE_SYNC_MODE=1 /home/kees/Install/android-studio/bin/studio.sh

Note

You will have to do that in the desktop/topbar item, changing the file seems to do nothing.

So for instance left click the android studio icon and alter the command to say :

script
env IBUS_ENABLE_SYNC_MODE=1 /home/kees/Install/android-studio/bin/studio.sh