Gradle无法添加编译的com.google.android.gms:play-services:7.0.0'

时间:2021-09-23 21:09:43

I can't belive that no one found out how to solve this problem. I wanted to add a banner to my app, but Android Studio's Gradle system tries to convience my that this is not so good idea. It looks like this:

我不敢相信没有人知道如何解决这个问题。我想给我的应用添加一个横幅,但是Android Studio的Gradle系统试图让我觉得这不是一个好主意。它看起来像这样:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.(package).(name)"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:7.0.0'
}

Log:

日志:

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.android.support:support-v4:22.0.0. Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom https://jcenter.bintray.com/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar file:/C:/Program Files (x86)/Android/sdk/extras/android/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom file:/C:/Program Files (x86)/Android/sdk/extras/android/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar file:/C:/Program Files (x86)/Android/sdk/extras/google/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom file:/C:/Program Files (x86)/Android/sdk/extras/google/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar Required by: FakeCall:app:unspecified > com.android.support:appcompat-v7:21.0.3 Could not find com.android.support:support-v4:22.0.0. Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom https://jcenter.bintray.com/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar file:/C:/Program Files (x86)/Android/sdk/extras/android/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom file:/C:/Program Files (x86)/Android/sdk/extras/android/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar file:/C:/Program Files (x86)/Android/sdk/extras/google/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.pom file:/C:/Program Files (x86)/Android/sdk/extras/google/m2repository/com/android/support/support-v4/22.0.0/support-v4-22.0.0.aar Required by: FakeCall:app:unspecified > com.google.android.gms:play-services:7.0.0 > com.google.android.gms:play-services-base:7.0.0

无法解决配置“:app:_debugCompile”的所有依赖项。找不到com.android.support:support-v4:22.0.0。在以下地点进行搜索:https://jcenter.bintray.com/com/android/support/support/supportv4/22.0.pom https://jcenter.bintray.com/com/android/support/support/supportv4/22.0.0/support - v4/22.0.aar文件:/C:/程序文件(x86)/Android/sdk/附加/Android/ m2repository/ support/support/support -v4-22.0.0。pom文件:/ C:/程序文件(x86)/ Android / sdk /配件/ Android / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。aar文件:C:/程序文件(x86)/谷歌Android / sdk /配件/ / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。pom文件:/ C:/程序文件(x86)/谷歌Android / sdk /配件/ / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。aar需要:FakeCall:app:未指定的> com.android.support:appcompat-v7:21.0.3无法找到com.android.support:support-v4:22.0.0。在以下地点进行搜索:https://jcenter.bintray.com/com/android/support/support/supportv4/22.0.pom https://jcenter.bintray.com/com/android/support/support/supportv4/22.0.0/support - v4/22.0.aar文件:/C:/程序文件(x86)/Android/sdk/附加/Android/ m2repository/ support/support/support -v4-22.0.0。pom文件:/ C:/程序文件(x86)/ Android / sdk /配件/ Android / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。aar文件:C:/程序文件(x86)/谷歌Android / sdk /配件/ / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。pom文件:/ C:/程序文件(x86)/谷歌Android / sdk /配件/ / m2repository /com/android/support/support-v4/22.0.0/support-v4-22.0.0。aar要求:FakeCall:app:未指定的> com.google.android.gms:play-services:7.0.0 > com.google.android.gms:play-service -base:7.0.0。

2 个解决方案

#1


7  

Via the SDK Manager, you need to make sure you have Android Support Repository up to date - that is where Android Support Library dependencies are resolved.

通过SDK管理器,您需要确保您有最新的Android支持存储库——这是Android支持库依赖的解决方案。

#2


2  

add compile 'com.android.support:support-v4:22.0.0'

添加编译“com.android.support:support-v4:22.0.0”

#1


7  

Via the SDK Manager, you need to make sure you have Android Support Repository up to date - that is where Android Support Library dependencies are resolved.

通过SDK管理器,您需要确保您有最新的Android支持存储库——这是Android支持库依赖的解决方案。

#2


2  

add compile 'com.android.support:support-v4:22.0.0'

添加编译“com.android.support:support-v4:22.0.0”