当前位置: 首页 > 知识库问答 >
问题:

gradle同步失败:找不到参数的方法实现(com.google.android.gms: play-services-ads: 18.2.0]

荆运诚
2023-03-14

我的项目中出现以下错误:11:28 Gradle sync失败:在类型为org的对象上找不到参数[com.google.android.gms:play services ads:18.2.0]的方法实现()。格雷德尔。应用程序编程接口。内部的人工制品dsl。依赖关系。DefaultDependencyHandler。(10秒801毫秒)

这就是构建。格雷德尔锉刀

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'
}

共有1个答案

壤驷升
2023-03-14

你使用gradle版本3吗。x或更高版本为gradle版本,4。x作为你的gradle插件?

项目级渐变文件:

dependencies{
    classpath 'com.android.tools.build:gradle:3.5.0'
}

Gradle插件分布在包装器属性中的Url配置:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

或者最新版本的课程

https://developer.android.com/studio/releases/gradle-plugin

您在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(模块:app) Build.Gradle(项目)

  • 我是Android应用开发新手。我正在尝试使用TabLayout创建一个Android应用程序,并在文件。 但在运行该应用程序时,我发现构建错误如下 Gradle sync失败:在类型为org的对象上找不到参数[directory'libs']的compile()方法。格雷德尔。应用程序编程接口。内部的人工制品dsl。依赖关系。DefaultDependencyHandler。有关更多详细信息,请

  • 我是Android应用程序开发新手。我正在尝试使用TabLayout创建一个Android应用程序,并在build.gradle文件中添加了以下依赖项。 但是在运行应用程序时,我得到了如下的构建错误 错误:(27, 0) 找不到 Gradle DSL 方法: 'compile()' 可能的原因: 关于为什么会出现这个问题的任何建议。我可以选择从Android Studio安装插件,但我不知道要安装

  • 问题内容: 我尝试在Android Studio中导入项目。导入时,我在Gradle中遇到了一个错误: 我努力了 : 重新下载依赖项并同步项目:失败(相同错误)。 停止Gradle构建过程:失败(相同错误)。 删除主目录中的.graddle:失败(相同错误)。 使缓存无效并重新启动失败(相同的错误)。 卸载并重新安装Android Studio和SDK:失败(相同错误)。 /build.gradl

  • 无法同步分级。 错误:找不到com.android.tools.build:gradle:1.0.0。在以下位置搜索:文件:/e:/installed/androidsdk/gradle/m2repository/com/android/tools/build/gradle/1.0.0/gradle-1.0.0.pom文件:/e:/installed/androidsdk/gradle/m2rep