Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 0.2 App that use Google Maps - Gradle modify

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.

like image 925
Pepa Zapletal Avatar asked Jul 15 '13 09:07

Pepa Zapletal


People also ask

How to build an app with the Google Maps SDK for Android?

Android Studio is the recommended development environment for building an app with the Maps SDK for Android. Step 1. Download Android Studio Follow the guides to download and install Android Studio. Step 2. Install the Google Play services SDK Add Google Play services to Android Studio. Step 3. Create a Google Maps project

How to use Google Maps API in Android Studio?

In order to use the Google MapsAPI, you must register your application on the Google Developer Console and enable the API. Table Of Contents 1Steps For Getting The Google Maps Api Key: 2Google Maps Example To Access User Current Location In Android Studio: 3Google Map Example To Draw A Route Between Two Locations In Android Studio:

How do I add a map to an Android app?

The overall process of adding a map to an Android application is as follows: Install Android Studio. Install and configure the Google Play services SDK, which includes the Maps SDK for Android. Get an API key. Add the required settings to your application's manifest.

How do I add a Google Play map to my project?

To do so, you need to manually configure your project and then add the map. Android Studio is required. If you haven't already done so, download and install it. Add the Google Play services SDK to Android Studio.


1 Answers

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!

like image 146
Paschalis Avatar answered Sep 27 '22 19:09

Paschalis