0

I am developing in Android , and try to implement GPS and Google Map.

The build.gradle(Module:app) is like the following

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        multiDexEnabled true
        applicationId "com.app.t.pro"
        minSdkVersion 21
        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(include: ['*.jar'], dir: 'libs')
    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.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.+'
    compile 'com.google.android.gms:play-services:11.0.4'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    testCompile 'junit:junit:4.12'
}

But it show the error at compile 'com.android.support:appcompat-v7:26.+'. The error is

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 25.2.0. Examples include com.android.support:animated-vector-drawable:26.1.0 and com.android.support:mediarouter-v7:25.2.0 less... (Ctrl+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

But I did not see any version-25 in build.gradle. Did I missing something? Thanks in advance.

Wun
  • 6,211
  • 11
  • 56
  • 101

2 Answers2

4

Set

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'

And

compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-location:11.4.2'

Also remove,

compile 'com.google.android.gms:play-services:11.4.2'
Sneh Pandya
  • 8,197
  • 7
  • 35
  • 50
  • But it will show **can not resolve symbol `import com.google.android.gms.location.LocationServices;`** when I remove `compile 'com.google.android.gms:play-services:11.4.2'`. – Wun Oct 12 '17 at 08:09
1

tl;dr You need to update the Google Play libraries to at least 11.2+

Check the Google Play Release Notes

SDK Version Support in 11.2

When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O). This does not change the way your app runs. You will not be required to update targetSdkVersion. If you update compileSdkVersion to 26, you may receive an error in your build with the following message referring to the Android support library:

This support library should should not use a different version (25) than the compileSdkVersion (26).

This error can be resolved by upgrading your support library dependencies to at least version 26.0.0.

Community
  • 1
  • 1
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245