5

I'm developing an App in Android studio. And I want use a Google maps API, but I can't use UI to configure project settings. I tried some different instruction to add maps, but it didn't work. I have to modify somehow build.gradle file? Can you tell me how? Does someone have experience with that?

Thanks for every advice.

ingh.am
  • 25,981
  • 43
  • 130
  • 177
Pepa Zapletal
  • 2,879
  • 3
  • 39
  • 69

1 Answers1

7

If you are on 0.2 it means that you already have Google Repository and Android Repository installed(from Android SDK: terminal$ android sdk).

One of them, has the Google Play services. Here is a full build.gradle for your module:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile 'com.google.android.gms:play-services:3.1.36'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16
    }
}

Notice how(easily) the play services can be included.

Also gradle version is 0.5.+ so it can be auto updated!

Also another VERY important thing, that wasted me a lot of time is the minimum sdk version! It must be 8 or above, since google play services aren't supported for lower versions!

Paschalis
  • 11,929
  • 9
  • 52
  • 82
  • 1
    If this doesnt work, you may want to read out my answer here http://stackoverflow.com/a/17663581/776345. It details the rest of the .gralde files, if you use libraries(sherlock?), etc! – Paschalis – Paschalis Jul 15 '13 at 20:51
  • Subquestion: How/where do you find out what version you should use? (3.1.36 for Play Services for example) – Thibault D. Sep 15 '13 at 13:17
  • 1
    @thibaultd, I used them from this G+ post: https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf . Keep an eye on Android Developers on G+ for latest updates regarding gradle/studio/android dev in general! – Paschalis Sep 15 '13 at 23:06
  • 1
    Thanks! Not so handy but I haven't found anywhere else :) – Thibault D. Sep 16 '13 at 06:45
  • 2
    @thibaultd [Gradle, please](http://gradleplease.appspot.com/) may be a bit more handy to you. – MaciejGórski Sep 25 '13 at 00:29