我尝试将Fresco库添加到我的项目中,方法是将其添加到我的应用级gradle文件中
implementation 'com.facebook.fresco:fresco:1.8.0'
然后我收到以下错误消息:
Gradle DSL method not found: 'implementation()' Possible causes:
The project may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 3.0.1 and sync project
The project may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
当我运行gradle --version时,它告诉我我正在使用gradle 4.5。
这是我的顶级gradle文件。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
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
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven"}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的应用级gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.example.project1.3"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "state1.0"
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// lots of other dependencies
implementation 'com.facebook.fresco:fresco:1.8.0'
}
我的gradle-wrapper.properties文件中也有这个。
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip
我基本上已经尝试了https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html的所有内容,但问题仍然存在。
非常感谢任何帮助。谢谢!
答案 0 :(得分:0)
我的猜测是,你的其他一个依赖项可能导致了这个问题, 我运行完全相同的应用程序&项目gradle文件您在新项目中提供并同步没有问题。
您可以尝试以下操作:
1)将implementation 'com.facebook.fresco:fresco:1.8.0'
替换为compile'com.facebook.fresco:fresco:1.8.0'
(已弃用,但有助于排查问题),看看它是否会正常同步。
2)启动一个新项目并使用相同的gradle文件,看看问题是否仍然存在。
如果无效,请发布完整的应用级gradle文件再次检查。