Android studio Gradle同步失败:找不到参数[com.google.android.gms:play services ads:18.2.0]的方法实现()
我的项目中出现以下错误: 11:28 Gradle同步失败:在org.Gradle.api.internal.artifacts.dsl.dependency.DefaultDependencyHandler类型的对象上找不到参数[com.google.android.gms:play services ads:18.2.0]的方法实现()。(10秒801毫秒) 这是build.gradle文件Android studio Gradle同步失败:找不到参数[com.google.android.gms:play services ads:18.2.0]的方法实现(),android-studio,gradle,build.gradle,Android Studio,Gradle,Build.gradle,我的项目中出现以下错误: 11:28 Gradle同步失败:在org.Gradle.api.internal.artifacts.dsl.dependency.DefaultDependencyHandler类型的对象上找不到参数[com.google.android.gms:play services ads:18.2.0]的方法实现()。(10秒801毫秒) 这是build.gradle文件 apply plugin: 'com.android.application' android {
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.flixarts.ar.*"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.2.1'
implementation 'com.android.support:design:27.2.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
}
您是否使用gradle版本3.x或更高版本作为您的gradle版本,以及4.x作为您的gradle插件 项目级渐变文件:
dependencies{
classpath 'com.android.tools.build:gradle:3.5.0'
}
包装器属性中的Gradle插件distributionUrl配置:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
当然是最新版本
注 您在build.gradle中使用了两次有问题的插件:
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
您是否使用gradle版本3.x或更高版本作为您的gradle版本,以及4.x作为您的gradle插件 项目级渐变文件:
dependencies{
classpath 'com.android.tools.build:gradle:3.5.0'
}
包装器属性中的Gradle插件distributionUrl配置:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
当然是最新版本
注 您在build.gradle中使用了两次有问题的插件:
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
build.gradle更新到最后一个版本build.gradle更新到最后一个版本Hi Levente你好吗?我的gradle版本和你在那里写的一模一样。我有两次插件播放服务广告,一次在build.gradle项目中,一次在build.gradle模块应用程序中。我必须删除哪一行?(其中gradle:build.gradle项目或build.gradle模块.app)如果您想保留18.2.0,那么您可能需要迁移到AndroidX(),因为18.0.0有一些重大更改。如果你同意继续使用17.2.0,那么就消除最新版本的依赖关系。嗨,Levente,你好吗?我的gradle版本和你在那里写的一模一样。我有两次插件播放服务广告,一次在build.gradle项目中,一次在build.gradle模块应用程序中。我必须删除哪一行?(其中gradle:build.gradle项目或build.gradle模块.app)如果您想保留18.2.0,那么您可能需要迁移到AndroidX(),因为18.0.0有一些重大更改。如果您可以继续使用17.2.0,那么就消除最新版本的依赖关系。