java 找不到参数的方法 implementation()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47744022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find method implementation() for arguments
提问by user7856586
I try to run my app, but gradle doesn`t want to compose it.
我尝试运行我的应用程序,但 gradle 不想编写它。
Can you tell me what should I do ?
你能告诉我我该怎么做吗?
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.
错误:(36, 0) 无法在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找到参数 [com.google.firebase:firebase-appindexing:11.6.2] 的方法 implementation() .
My app build.gradle file
我的应用程序 build.gradle 文件
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'
}
回答by Roberto Martucci
Replace
代替
implementation 'com.google.firebase:firebase-appindexing:11.6.2'
with
和
compile 'com.google.firebase:firebase-appindexing:11.6.2'
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
您需要更新您的 gradle 版本才能使用implementation
. 你可以在你的项目 build.gradle 中更新你的 buildscript 块
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
has been deprecated and it will be no longer supported in future gradle releases.
compile
已被弃用,未来的 gradle 版本将不再支持它。
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.
因此,要让您的项目编译只需按照我的建议更改该行,但请考虑更新您的 gradle 版本并implementation
用于所有依赖项。
UPDATE
更新
You should use the same version for all the modules of your firebase dependencies.
您应该对 firebase 依赖项的所有模块使用相同的版本。
So you could need to update your app build.gradle this way
所以你可能需要以这种方式更新你的应用 build.gradle
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.
或者您可能有新的构建错误。
Also
还
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 :)
但我建议逐步进行:)
UPDATE 2
更新 2
If you declare a dependency for gson this way
如果您以这种方式声明 gson 的依赖项
compile 'com.google.code.gson:gson:2.8.0'
You don't need
你不需要
compile files('libs/gson-2.8.0.jar')
It is redundant and plus you can free your libs folder of a useless jar file
这是多余的,而且你可以释放你的 libs 文件夹中一个无用的 jar 文件