Unable instantiate android.gms.maps.MapFragment

In IntelliJ IDEA (updated for IntelliJ 12):

  1. Create a file ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/src/dummy.java containing class dummy {}.
  2. File->Import Module-> ~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
  3. Create Module from Existing Sources
  4. Next->Next->Next->Next->Finish
  5. File->Project Structure->Modules->YourApp
  6. +->Module Dependency->Google-play-services_lib (The + button is in the top right corner of the dialog.)
  7. +->Jars or directories->~/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
  8. Use the up/down arrows to move <Module source> to the bottom of the list.

You can delete dummy.java if you like.

Edit: After using this for a while I’ve found that there is a small flaw/bug. IDEA will sometimes complain about not being able to open a .iml project file in the google-play-services_lib directory, despite the fact that you never told it there was a project there. If that happens, rebuilding the project solves the problem, at least until it comes back.

Leave a Comment