Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误:找不到Gradle DSL方法:';编译()';_Java_Android_Api_Gradle - Fatal编程技术网

Java 错误:找不到Gradle DSL方法:';编译()';

Java 错误:找不到Gradle DSL方法:';编译()';,java,android,api,gradle,Java,Android,Api,Gradle,我正在尝试使用YelpFusion android库。我试图更新gradle,但没有成功 我得到这个错误: ERROR: Gradle DSL method not found: 'compile()' Possible causes: The project 'testProject' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file The build fi

我正在尝试使用YelpFusion android库。我试图更新gradle,但没有成功

我得到这个错误:

ERROR: Gradle DSL method not found: 'compile()'
Possible causes:
The project 'testProject' 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
下面是build.gradle:

buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
你的问题就在这里 编译“io.github.ranga543:yelp fusion客户端:0.1.4”

不推荐使用Compile,请改用“实现”

你把它放错了梯度有两个梯度文件 请注意这个警告 //注意:不要将应用程序依赖项放在此处;他们属于
//在单个模块build.gradle文件中,将依赖项放在app模块的下方,而不是主项目gradle

compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
用实现代替编译。 e、 g(在应用程序模块中)


从顶级文件中删除这一行:

//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
app/build.gradle
文件中,您可以添加相同的依赖项:

dependencies {
    ...
    implementation 'io.github.ranga543:yelp-fusion-client:0.1.5'
    ...
}

buildscript
中的
依赖项
部分不适用于模块依赖项。因此。从本节中移出
编译'io.github.ranga543:yelp fusion client:0.1.4'
,创建顶级依赖项块并将其放入其中,如下所示:

buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

dependencies {
    compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
    }

此外,如果您有子模块,则可以将此依赖项添加到子模块。

您的gradle版本是什么?为什么要在模块中添加应用依赖项gradle它应该在应用程序构建中。gradle这是否回答了您的问题?
buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

dependencies {
    compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
    }