找不到参数的方法Implementation() [英] Could not find method implementation() for arguments

查看:499
本文介绍了找不到参数的方法Implementation()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行我的应用程序,但是gradle不想编写它.

I try to run my app, but gradle doesn`t want to compose it.

你能告诉我该怎么办吗?

Can you tell me what should I do ?

错误:(36,0)在类型为org.gradle.api.internal.artifacts.dsl的对象上找不到参数[com.google.firebase:firebase-appindexing:11.6.2]的方法实现().依赖项.DefaultDependencyHandler.

Error:(36, 0) Could not find method implementation() for arguments [com.google.firebase:firebase-appindexing:11.6.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

我的应用程序build.gradle文件

My app build.gradle file

 minSdkVersion 14
        targetSdkVersion 22
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        disable 'MissingTranslation'
    }
    productFlavors {
    }
}
dependencies {
    implementation 'com.google.firebase:firebase-appindexing:11.6.2'
    compile project(':AndEngine')
    compile files('libs/gson-2.8.0.jar')
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-ads:10.2.4'
    compile 'com.google.firebase:firebase-ads:10.2.4'
    compile 'com.google.firebase:firebase-crash:10.2.4'

} 

推荐答案

替换

implementation 'com.google.firebase:firebase-appindexing:11.6.2'

compile 'com.google.firebase:firebase-appindexing:11.6.2'

您需要更新gradle版本才能使用implementation. 您可以在项目build.gradle

You need to update your gradle version in order to use implementation. You can do that updating your buildscript block in your project build.gradle

buildscript {

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


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

compile已被弃用,将来的gradle版本将不再支持.

compile has been deprecated and it will be no longer supported in future gradle releases.

因此,要让您的项目进行编译,只需按照我的建议更改该行,但可以考虑更新gradle版本,并对所有依赖项使用implementation.

So to let your project compile just change that line as I suggested, but consider to update your gradle version and use implementation for all your dependencies.

更新

您应该对Firebase依赖项的所有模块使用相同的版本.

You should use the same version for all the modules of your firebase dependencies.

所以您可能需要以这种方式更新您的应用程序build.gradle

So you could need to update your app build.gradle this way

dependencies {
    compile 'com.google.firebase:firebase-appindexing:11.6.2'
    compile project(':AndEngine')
    compile files('libs/gson-2.8.0.jar')
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.firebase:firebase-core:11.6.2'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-ads:11.6.2'
    compile 'com.google.firebase:firebase-ads:11.6.2'
    compile 'com.google.firebase:firebase-crash:11.6.2'
} 

或者您可能会遇到新的构建错误.

Or you might have new build errors.

compile 'com.android.support:support-v4:22.2.1'

不是最新版本,可能会带来新问题.

is not the latest version and might bring new issues.

但是我建议逐步进行:)

But I suggest to proceed step by step :)

更新2

如果您以此方式声明gson的依赖关系

If you declare a dependency for gson this way

compile 'com.google.code.gson:gson:2.8.0'

您不需要

compile files('libs/gson-2.8.0.jar')

这是多余的,而且您可以释放无用的jar文件的libs文件夹

It is redundant and plus you can free your libs folder of a useless jar file

这篇关于找不到参数的方法Implementation()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆