【发布时间】:2019-05-11 16:16:40
【问题描述】:
我的项目正在运行。但是当我尝试打开项目时,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
}
App 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'
【问题讨论】:
-
查看错误上方自动生成的注释" // 注意:不要将应用程序依赖项放在这里;它们属于 // 在单个模块 build.gradle 文件中"
-
尝试从应用项目而不是脚本将其添加到 build.gradle 中,而且 googleservices 4 看起来已经过时,尝试找到最近的
-
当我将它移到应用程序级别时。它给出了这个错误“找不到ID为'com.google.gms.google-services'的插件。”