Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 833
timv Avatar asked Jun 20 '17 01:06

timv


2 Answers

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.

like image 105
timv Avatar answered Nov 18 '22 11:11

timv


Add these lines to your build.gradle file to get libraries that you don't have based on Google site.

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Caution: Using dynamic dependencies (for example, palette-v7:23.0.+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a library version (for example, palette-v7:25.4.0).

like image 31
Mehran Zamani Avatar answered Nov 18 '22 10:11

Mehran Zamani