【问题标题】:Could not find com.google.gms:google-services:3.1.1找不到 com.google.gms:google-services:3.1.1
【发布时间】:2018-09-25 08:34:28
【问题描述】:

我得到了例外:

Could not find com.google.gms:google-services:3.1.1. 

当我开始我的 android 项目时。

我的 build.gradle(项目:android)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

还有 build.gradle(模块:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "de.derdoenerdon.ressourcencockpit"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:support-v4:25.4.0'
    implementation 'com.android.support:recyclerview-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.4.0'


    compile 'com.github.OPCFoundation:UA-Java:1.03.342.0'


    testCompile 'junit:junit:4.12'
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.7'

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.1.1'
    }
}
apply plugin: 'com.google.gms.google-services'

如有任何帮助,我将不胜感激。我是安卓新手。 它发生了,因为我尝试在我的应用程序中使用 firebase 并且它自动在我的应用程序中添加了一些依赖项。 非常感谢

编辑: 这就是我的 gradle.build (Module: app) 现在的样子:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "de.derdoenerdon.ressourcencockpit"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:support-v4:25.4.0'
    implementation 'com.android.support:recyclerview-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:25.4.0'


    implementation 'com.github.OPCFoundation:UA-Java:1.03.342.0'


    testImplementation 'junit:junit:4.12'
    testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.7'

}


apply plugin: 'com.google.gms.google-services'

这是警告,我将其作为输出:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html 

有人知道如何删除此警告吗?谢谢

【问题讨论】:

    标签: android gradle android-gradle-plugin


    【解决方案1】:

    添加类路径

     'com.google.gms:google-services:3.1.1'
    

    在项目gradle中的dependencies不在module.app gradle中如下:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.1'
            classpath 'com.google.gms:google-services:3.1.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io" }
            google()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    【讨论】:

    • @NewGenerationFashion 在编辑答案后检查并告诉我是否一切正常 :)
    • dependencies { classpath 'com.android.tools.build:gradle:3.1.1' classpath 'com.google.gms:google-services:3.1.1' // 注意:不要将你的此处的应用程序依赖项;它们属于 // 在单个模块 build.gradle 文件中} 这是项目 gradle 中依赖项的外观,我得到这个:找不到 com.google.gms:google-services:3.1.1。要求:project :app 在 build.gradle 文件中搜索 - Salam
    • buildscript { dependencies { classpath 'com.google.gms:google-services:3.1.1' } } 抱歉,我在 Module:app 的 gradle.build 中删除了上面的这个,现在我明白了:忽略指定的 Android SDK Build Tools 版本 (26.0.2),因为它低于 Android Gradle Plugin 3.1.1 的最低支持版本 (27.0.3)。将使用 Android SDK 构建工具 27.0.3。要禁止显示此警告,请从您的 build.gradle 文件中删除“buildToolsVersion '26.0.2'”,作为 Android Gradle 插件的每个版本
    • 类路径 'com.google.gms:google-services:3.1.0' 不是 3.1.1
    • 忽略指定的 Android SDK 构建工具版本 (26.0.2),因为它低于 Android Gradle 插件 3.1.1 的最低支持版本 (27.0.3)。将使用 Android SDK 构建工具 27.0.3。要禁止显示此警告,请从您的 build.gradle 文件中删除“buildToolsVersion '26.0.2'”,因为每个版本的 Android Gradle 插件现在都有一个默认版本的构建工具。更新构建工具版本并同步项目打开文件我在上面得到了这个..如果你能帮助我,我会很高兴谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 2019-05-11
    • 2019-05-11
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    相关资源
    最近更新 更多