为 Fusion 位置提供程序添加播放服务时编译 AppCompat v7:26.+ 错误



我有一个问题,并且查看了可能重复的问题和答案,我认为其他人没有回答这个问题,所以在这里问。

我更新了我的游戏服务以使用融合的位置提供程序,现在我的 gradle 中的 appcompat 显示错误。

所以我创建了一个新项目并检查了新项目上的build.gradle,并且具有完全相同的appcompat,但我的项目显示错误。

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'
}

显示错误的这一行:

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

但在一个新项目中,它很好。 为什么我会收到错误?

更新:

如果我删除这两行,则错误将消失:

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

但是我需要它们,所以仍然有错误。

将这些行添加到您的build.gradle文件中,以获取您没有的基于 Google 网站的库。

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

警告: 使用动态依赖项(例如,palette-v7:23.0.+(可能会导致意外的版本更新和回归不兼容。建议您显式指定库版本(例如,palette-v7:25.4.0(。

终于在

ZeroOne对类似问题的回答的帮助下解决了这个问题。

是什么让我看到ZeroOnes的答案是谷歌给了我原因,而不是错误。 我的问题是以下行包罗万象,并且添加了许多额外的依赖项,这将使应用程序不必要地变大。

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

我只需要更具体,错误就消失了。

这是最后的成绩。

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'
}

这是我将上面更改为的特定行:

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

希望它可以帮助遇到相同问题的人。

更具体地使用编译'com.google.android.gms:play-services-location:11.0.1'而不是编译'com.google.android.gms:play-services:11.0.1'也保存了我的项目,tks很多人。

最新更新