Android + Google Play Services

Hello there,
I am trying to create a simple app that makes use of the Google Maps API v2. Basically how it is described in the official guide:
This is fairly simple using Eclipse and took me about 20 minutes, when considering some further setup options as for example described here:

However, it seems impossible to me to add the "google-play-service_lib" project as an dependency to IntelliJ as it is described for Eclipse. Instead I added the jars (Google Play Services and the Android Support Package) as two module dependencies to my main IntelliJ module what I also found the cleaner solution. The compiler will not complain about this, however whenever I start the very same app as I wrote before using Eclipse, the app will crash imediately with IntelliJ. The stack trace tells me:

at com.example.maptest.MainActivity.onCreate(

When not adding the libraries I get (as expected):

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maptest/com.example.maptest.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
Caused by:$InstantiationException: Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor that is public
Caused by: java.lang.ClassNotFoundException:

since the Google Play Service Classes are simply missing. If I import the google-play-service_lib SDK project as a module, the same thing happens.
If I however add the entire SDK project folder (google-play-service_lib) as a module dependency I get:

Android Dex: [maptest] java.lang.IllegalArgumentException: already added: Landroid/UnusedStub;

what does not really tell me anything

I am using SDK version 16 (4.1.2) to build my app and test on a Sony Xperia Z. I am using Intellij CE 12. As I said, everything worked with Eclipse (which I do not want to use).
Any ideas? Thank you guys so much! I also attached the sample project to this thread.

1 comment
Comment actions Permalink

Nevermind. This solved my problem:

  1. Create a file
    class dummy {}
  2. File->Import Module->
  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->
  8. Use the up/down arrows to move
    <Module source>
    to the bottom of the list.

Please sign in to leave a comment.