17

I've used the Maps APIs many times before and not had this problem, but I've clearly done something wrong with this IntelliJ project. Under Settings->SDKs I have specified the platform 7 Google API in the classpath - it still fails to build saying the Maps APIs are not there. I have also tried added a separate reference to the classpath to the Google APIs .jar, but still the same problem.

How do I fix my IntelliJ IDE project so it correctly builds against the Google APIs?

It's been a long day, I am probably missing something obvious.

Ollie C
  • 28,313
  • 34
  • 134
  • 217

3 Answers3

37

So to get the Google (Maps etc) APIs working in IntelliJ:

  1. Under File->Project Structure->SDKs add an item for the platform level you're targetted. Under the classpath tab add a reference to the top of the android SDKs folder, and use the Build Target menu to specify which platform to target.
  2. Under Settings->Project Structure->Modules->Dependencies select the SDK version from the "Module SDK" list
  3. If you need to target the Google (Maps etc) APIs then under Settings->Project Structure->SDKs->Classpath make sure you ALSO add a reference the .jar file for the Google APIs for that platform version (e.g. addons/addon_google_apis_google_inc_8/libs/maps.jar
Community
  • 1
  • 1
Ollie C
  • 28,313
  • 34
  • 134
  • 217
  • 2
    Or just choose Google APIs platform and this jar will be added automatically. – CrazyCoder Jun 08 '11 at 19:40
  • Hmm, wasn't for me. Glad to have it working though - I find the IntelliJ project structure dialogs pretty confusing. – Ollie C Jun 09 '11 at 13:11
  • 2
    actually I can just go to 'module settings' - 'platform settings' - 'SDKs' - select the platform and then change the build target to GOOGLE APIS :) – Dori Apr 19 '12 at 14:02
  • 1
    That jar file gets me every time. – SharkAlley Jun 28 '13 at 03:02
  • This is what did it for me as well. I have imported this same project that has heavily used google maps on different computers using intellij idea, and despite the fact that I am using git, I still continue to face this problem and require this solution. – Daniel Viglione Apr 01 '16 at 17:35
2

Under my version of Idea, the controls are a bit different:

Project settings -- Modules -- (ModuleName) -- triangle to unfold the tree -- Android; and on the right you see "Android platform:" and a selection control. There is no "Android 2.1-update1 Google APIs" in that control, but you press the "New" button and... select an existing directory with downloaded stuff, e.g. /android-sdk-mac_x86/platforms/android-9

I still don't understand why it reads "New", but it works.

18446744073709551615
  • 16,368
  • 4
  • 94
  • 127
1

I use the newest 0.8.9 version and I must say there is no File->Settings option and the preferences reached by clicking the tool icon have no Modules section inside. How do I fix my problems with import com.google.android.gcm.GCMRegistrar; not found?