0

for the first time I am using google maps in my android studio project I have added the dependency in my project but i ma geeting error

Here is all the code from build.gradle(project:Location) file of my project

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

here is the all the code from build.gradle(Module.app) file of my project

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.anonymous.location"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.google.android.gms.play-services:+7'
    testCompile 'junit:junit:4.12'
}

Here is the all code from my AndroidMenifest.xml file of my project

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.anonymous.location">

    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/
               google_play_services_version"/>

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Johon smuthio
  • 496
  • 2
  • 8
  • 17

3 Answers3

1

compile 'com.google.android.gms.play-services:+7'

it should be-

compile 'com.google.android.gms:play-services:7+'

but you should avoid inexact versions, use more specific like "9.4.0" or whatever suits your application.

https://developers.google.com/android/guides/releases check here for the versions. check what functionality you want and use that version code. Also note the different variant of play-services are available.

Arnav M.
  • 2,560
  • 1
  • 25
  • 41
1

Like Arnav said, you have to use -

compile 'com.google.android.gms:play-services:7+'

Adding to that, if you want to check the latest dependency for any library, use this - Check latest version of any library

Sachin Aggarwal
  • 1,055
  • 8
  • 16
0

First of all, you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.

Here's the full detail

Daksh Gargas
  • 3,028
  • 1
  • 18
  • 33
  • It is wrong. The latest versions are not in the SDK Manager – Gabriele Mariotti Sep 29 '17 at 17:11
  • Dude, use compile `com.google.android.gms:play-services:11.0.1` – Daksh Gargas Sep 30 '17 at 06:09
  • You'll only be able to install Play Services SDK from that. You still have to define latest version inside `build.gradle` file – Daksh Gargas Sep 30 '17 at 06:10
  • It is again completely wrong. Now you can use 11.4.0, and since 11.2.0 you can find them only in the google maven repo. Check https://stackoverflow.com/questions/46417939/failed-to-resolve-com-google-android-gms-play-services-auth11-4-0/46418438#46418438 – Gabriele Mariotti Sep 30 '17 at 06:40
  • Yea, just sayin bro. Do whatever you want. Use any version you want. They always keep on updating it. I didn't check the latest version. – Daksh Gargas Sep 30 '17 at 07:25
  • Dennis "You'll only be able to install Play Services SDK from that", It is not correct. You will not find the latest versions in SDK Manager – Gabriele Mariotti Sep 30 '17 at 07:29
  • Dude, it's just that one needs to have Play Services SDK installed on his IDE in order to perform further functions. That gradle file has nothing to do with it. – Daksh Gargas Sep 30 '17 at 07:48