timv timv - 3 years ago 258
Android Question

compile appcompat v7:26.+ error when adding play services for fusion location provider

I have an issue and have looked at possible duplicate questions and answers and I think this one is not answered by the others so asking it here.

I updated my play services to make use of the fused location provider and now the appcompat in my gradle is showing an error.

So I created a new project and checked the build.gradle on the new project and have exactly the same appcompat but my project is showing an error.

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "au.com.itmobilesupport.sqltwo"
minSdkVersion 17
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:recyclerview-v7:26.+'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services:11.0.1'
}


Its this line that is showing the error:

compile 'com.android.support:appcompat-v7:26.+'


But in a new project its fine. Why am I getting the error?

UPDATE:

If I remove these two lines then the error goes away:

compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services:11.0.1'


But I need them so still have the error.

Answer Source

Finally solved the issue with the help of ZeroOne's answer to a similar question.

What led me to look at ZeroOnes answer was Google giving me the reason but not as an error. My issue was that the following line is too encompassing and a lot of extra dependencies were added that would have made the app unnecessarily larger.

compile 'com.google.android.gms:play-services:11.0.1'

I simply needed to be more specific and the error disappeared.

Here is the final gradle.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "au.com.itmobilesupport.sqltwo"
        minSdkVersion 17
        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:recyclerview-v7:26.+'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-maps:11.0.1'
    compile 'com.google.android.gms:play-services-location:11.0.1'
}

And this is the specifc line I change the above to:

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

Hope it helps someone who comes across the same issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download