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

查看:42
本文介绍了找不到参数的方法 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] 的方法 implementation().dependencies.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')

这是多余的,而且你可以释放你的 libs 文件夹中一个无用的 jar 文件

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

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

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