Android 编译appcompat v7:26.&x2B;为fusion location provider添加播放服务时出错

Android 编译appcompat v7:26.&x2B;为fusion location provider添加播放服务时出错,android,gradle,android-gradle-plugin,Android,Gradle,Android Gradle Plugin,我有一个问题,并且已经研究了可能重复的问题和答案,我认为其他人没有回答这个问题,所以在这里提问 我更新了我的播放服务以使用融合的位置提供程序,现在我的gradle中的appcompat显示错误 apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.0" defaultConfig { applicationId "au.com.itmobilesupp

我有一个问题,并且已经研究了可能重复的问题和答案,我认为其他人没有回答这个问题,所以在这里提问

我更新了我的播放服务以使用融合的位置提供程序,现在我的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'
}
因此,我创建了一个新项目,并检查了新项目上的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'

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

最终在一个类似问题的帮助下解决了这个问题

谷歌给了我一个理由,但不是一个错误,这让我看到了“零一”的答案。我的问题是,下面这行内容太笼统,添加了很多额外的依赖项,这会使应用程序变得不必要地更大

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'

希望它能帮助遇到同样问题的人。

将这些行添加到您的
build.gradle
文件中,以获取您没有的库


更具体地说,使用compile'com.google.android.gms:play services location:11.0.1'而不是compile'com.google.android.gms:play services:11.0.1'也保存了我的项目,这让很多人感到惊讶。

似乎只是com.google.android.gms:play services行导致了错误。仍在寻找解决方案也请查看此项,因为它非常有用。我没有任何play services代码,但即使在(更新后)我开始一个新项目时,我仍然会得到这个代码。我试过使用准确的版本号,但没有用。这篇StackOverflow帖子是谷歌在我精确搜索这个特定错误时返回的唯一一个网页(添加“避免使用+blah blah”)@user4500,我很高兴它帮助了某人。