简体   繁体   中英

ERROR: Gradle DSL method not found: 'compile()'

I'm trying to use yelp-fusion-android library. I tried updating the gradle but no luck.

I am getting this error:

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

Here is 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
}

Your problem is here compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

Compile is deprecated use "Implementation" instead

and you are placing it in the wrong gradle there are 2 gradle files please note this warning // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files

Place below dependency in app module instead of main project gradle.

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

and replace compile with Implementation. eg (In app module)

Implementation 'io.github.ranga543:yelp-fusion-client:0.1.4'

Remove this line from the top-level file:

//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

In the app/build.gradle file you can add the same dependency:

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

dependencies section inside buildscript is not for module dependencies. Hence. move out compile 'io.github.ranga543:yelp-fusion-client:0.1.4' from this section and create top level dependencies block and put it there as below:

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'
    }

Also, if you have got submodule then you can add this dependency to the sub-module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM