Unsupported Gradle DSL method found: 'compile()'!

前端 未结 5 1826
南方客
南方客 2020-12-14 23:29

I\'m going through Google\'s documentation on \"Add Google Play Services to Your Project\" in Android Studio: https://developer.android.com/google/play-services/setup.html

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 23:58

    Think of “Gradle DSL method” as a Java method. So in Gradle, methods can be distinguished by either {} or “.”. So

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
    }
    

    is the same as

    dependencies.compile fileTree(dir: 'libs', include: ['*.jar'])
    

    where both “dependencies” and “compile” are methods.

    So you are including a method somewhere in your build.gradle file that is not supported by your program. For example, make your dependencies this:

    dependencies {
        nothing 'this.does.nothing.build:gradle:0.7.+'
    }
    

    Which is the same as writing:

    dependencies.nothing 'this.does.nothing.build:gradle:0.7.+'
    

    And you will see an error saying “unsupported Gradle DSL method found: ‘nothing()’!” Obviously "nothing" is not a real method. I just made it up.

    So one of your "compile" methods inside your build.gradle is wrong.

提交回复
热议问题