找不到参数[com.google.gms:google-services:4.0.0]的方法compile()

时间:2018-12-10 18:00:15

标签: android android-studio

我的项目正在运行。但是当我尝试打开项目时,android studio给出了错误:

  

在类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象上找不到参数[com.google.gms:google-services:4.2.0]的方法compile()。

项目gradle文件如下:

buildscript {
ext.kotlin_version = '1.2.61'
repositories {
    google()
    jcenter()
}
dependencies {


    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

    compile 'com.google.gms:google-services:4.2.0'

    }
    }

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

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

应用gradle文件如下:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.asnus.moviefinder"
    minSdkVersion 19
    targetSdkVersion 28
    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(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'com.android.support:appcompat-v7:28.0.0-rc01'
compile 'com.android.support.constraint:constraint-layout:1.1.2'
compile 'com.android.support:support-v4:28.0.0-rc01'
compile 'com.android.support:design:28.0.0-rc01'

testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'

//cardview
compile "com.android.support:cardview-v7:28.0.0-rc01"
//recylerview
compile 'com.android.support:recyclerview-v7:28.0.0-rc01'
//picasso
compile 'com.squareup.picasso:picasso:2.71828'

//retrofit
compile 'com.squareup.retrofit2:retrofit:2.4.0'
compile 'com.squareup.retrofit2:converter-gson:2.4.0'

//Firebase

compile 'com.google.firebase:firebase-auth:16.0.3'
compile 'com.google.android.gms:play-services-auth:16.0.0'
compile 'com.google.firebase:firebase-firestore:17.1.0'

//Seekbar
compile 'com.crystal:crystalrangeseekbar:1.0.0'

//Search Dialog
compile 'com.github.mirrajabi:search-dialog:1.1'

//Fab Button
compile 'com.github.dimorinny:floating-text-button:0.0.4'

//Circle ImageView
compile 'de.hdodenhof:circleimageview:2.1.0'

 }

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

2 个答案:

答案 0 :(得分:1)

compile 'com.google.gms:google-services:4.2.0'依赖项从项目的build.gradle移至应用程序的build.gradle文件。

答案 1 :(得分:0)

像这样在项目的maven { url 'https://dl.bintray.com/android/android-tools' }中添加build.gradle

buildscript {
   repositories {
      maven { url 'https://dl.bintray.com/android/android-tools' }
      ...
   }
}

有关更多信息,请参见此answer