首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未找到DSL方法: implementation()

未找到DSL方法: implementation()
EN

Stack Overflow用户
提问于 2018-01-29 22:21:48
回答 1查看 1.9K关注 0票数 0

我尝试通过将以下代码添加到我的应用级gradle文件来将Fresco库添加到我的项目中

代码语言:javascript
运行
复制
implementation 'com.facebook.fresco:fresco:1.8.0'

然后我得到了下面的错误消息:

代码语言:javascript
运行
复制
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文件。

代码语言:javascript
运行
复制
// 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文件:

代码语言:javascript
运行
复制
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文件中也有这个。

代码语言:javascript
运行
复制
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip

我基本上已经尝试了从这里开始的所有方法,https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html,但问题仍然存在。

任何帮助都将不胜感激。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2018-01-31 06:49:01

我的猜测是,可能是你的其他依赖项导致了这个问题,我运行的应用程序和项目gradle文件与你在新项目中提供的完全相同,并且没有任何问题。

您可以尝试以下操作:

1)将implementation 'com.facebook.fresco:fresco:1.8.0'替换为compile'com.facebook.fresco:fresco:1.8.0' (已弃用,但有助于排查故障),并查看是否可以正常同步。

2)启动一个新项目,使用相同的gradle文件,看看问题是否仍然存在。

如果没有工作,请张贴完整的应用程序级gradle文件再次检查。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48503418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档