How do I set up IntelliJ IDEA for Android applications?
Asked Answered
K

7

280

How do I set up IntelliJ IDEA for Android applications?

Kenwee answered 11/3, 2011 at 9:33 Comment(1)
This is a perfectly good StackOverflow question.Sandasandakan
K
399

I've spent a day on trying to put all the pieces together, been in hundreds of sites and tutorials, but they all skip trivial steps.

So here's the full guide:

  1. Download and install Java JDK (Choose the Java platform)
  2. Download and install Android SDK (Installer is recommended)
  3. After android SD finishes installing, open SDK Manager under Android SDK Tools (sometimes needs to be opened under admin's privileges)
  4. Choose everything and mark Accept All and install.
  5. Download and install IntelliJ IDEA (The community edition is free)
  6. Wait for all downloads and installations and stuff to finish.

New Project:

  1. Run IntelliJ
  2. Create a new project (there's a tutorial here)
  3. Enter the name, choose Android type.
  4. There's a step missing in the tutorial, when you are asked to choose the JDK (before choosing the SDK) you need to choose the Java JDK you've installed earlier. Should be under C:\Program Files\Java\jdk{version}
  5. Choose a New platform ( if there's not one selected ) , the SDK platform is the android platform at C:\Program Files\Android\android-sdk-windows.
  6. Choose the android version.
  7. Now you can write your program.

Compiling:

  1. Near the Run button you need to select the drop-down-list, choose Edit Configurations
  2. In the Prefer Android Virtual device select the ... button
  3. Click on create, give it a name, press OK.
  4. Double click the new device to choose it.
  5. Press OK.
  6. You're ready to run the program.
Kenwee answered 11/3, 2011 at 9:34 Comment(11)
On a Mac, the Java JDK appears at /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdkHomochromatic
The "Prefer Android Virtual device" dropdown may not show AVDs that are not compatible with your app's targeted SDK version (see 'uses-sdk' tag in AndroidManifest.xml).Inarch
There is also a free course on Android development with IntelliJ, but it doesn't cover the Android SDK installation. tutsplus.com/course/android-for-the-busy-developerAnsilme
Excellent guide! You should also add to make sure the Android plugins are installed in IntelliJ.Heisler
I get the error "Please specify Android SDK" when I open the SDK ManagerAnesthesiology
On Mac, SDK Manager is accessible by running the 'android' file inside the tools directory. You may get a permissions error when running from Finder - it will work in terminal: ./androidLetourneau
Like ozmike noted in their answer, since 2013 the Google provided Android Studio (from your 2nd link) is based on IntelliJ.Divalent
For me, Android sdk was here: C:\Users\{User name}\AppData\Local\Android\sdk NOTE: AppData folder is hidden, click 'show hidden files' in IntelliJ file chooser.Stulin
The compiling part here is most relevant to me The ... button refers to little box on right with the text "..."Unicef
You can also go to tools > manage avd in the sdk manager (by invoking the android executable on command line)Unicef
Where can I find the installer? I can only find the download for the entire IDE.Rushy
M
27

The 5th step in "New Project' has apparently changed slightly since.

Where it says android sdk then has the drop down menu that says none, there is no longer a 'new' button.

  • 5.)

    • a.)click the ... to the right of none.
    • b.)click the + in the top left of new window dialog. (Add new Sdk)
    • c.)click android sdk from drop down menu
    • d.)select home directory for your android sdk
    • e.)select java sdk version you want to use
    • f.)select android build target.
    • g.)hit ok!
Modulation answered 15/8, 2011 at 19:58 Comment(0)
V
27

Once I have followed all these steps, I start to receive error messages in all android classes calls like:

Cannot resolve Android Classes

I revolved that including android.jar in the SDKs Platform Settings:

SKDs Classpath

Vivian answered 16/2, 2013 at 14:30 Comment(2)
it's out of the question, but may I ask what theme color you are using? Your syntax highlighting is also different.Backsaw
Somehow these screenshots tell more than lots of text. In my (also MacOS) case IntelliJ created a project structure with only /data/res in Classpath tab, and removing/reinserting Android 4.3 Platform, it as in the screenshot above, resolved the issue of unrecognized android dependencies.Bichloride
A
5

I had some issues that this didn't address in getting this environment set up on OSX. It had to do with the solution that I was maintaining having additional dependencies on some of the Google APIs. It wasn't enough to just download and install the items listed in the first response.

You have to download these.

  1. Run Terminal
  2. Navigate to the android/sdk directory
  3. Type "android" You will get a gui. Check the "Tools" directory and the latest Android API (at this time, it's 4.3 (API 18)).
  4. Click "Install xx packages" and go watch an episode of Breaking Bad or something. It'll take a while.
  5. Go back to IntelliJ and open the "Project Structure..." dialog (Cmd+;).
  6. In the left panel of the dialog, under "Project Settings," select Project. In the right panel, under "Project SDK," click "New..." > Android SDK and navigate to your android/sdk directory. Choose this and you will be presented with a dialog with which you can add the "Google APIs" build target. This is what I needed. You may need to do this more than once if you have multiple version targets.
  7. Now, under the left pane "Modules," with your project selected in the center pane, select the appropriate module under the "Dependencies" tab in the right pane.
As answered 11/9, 2013 at 1:26 Comment(0)
C
4

Just in case someone is lost. For both new application or existing ones go to File->Project Structure. Then in Project settings on the left pane select Project for the Java SDK and select Modules for Android SDK.

Convulsant answered 17/4, 2013 at 17:50 Comment(0)
P
4

Another way to identify the correct SDK is to install Android Studio, create a new project, go to project structure, SDK Location and find where the SDK was installed.

I found using the default installation process on a mac that the SDK home folder was in the /Users/'yourUser'/Library/Android/sdk folder. Make sure you have enabled your Mac to view the Library folder.

Pimply answered 13/1, 2017 at 1:38 Comment(0)
M
1

You just need to install Android development kit from http://developer.android.com/sdk/installing/studio.html#Updating

and also Download and install Java JDK (Choose the Java platform)

define the environment variable in windows System setting https://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows

Voila ! You are Donezo !

Markman answered 12/5, 2014 at 14:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.