Android studio build script error,unsupported gradle DSL method found : android()!

后端 未结 2 649
忘了有多久
忘了有多久 2021-01-22 00:51

I upgraded the Android Studio to AS 0.6 then imported the project developed in AS 0.3

I am getting errors like:

Build script error,unsupported Gradle DSL         


        
相关标签:
2条回答
  • 2021-01-22 00:56

    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 "android" methods is wrong.

    0 讨论(0)
  • 2021-01-22 01:16

    Actually it stated in the error message. So just add

    apply plugin: 'com.android.application'
    

    between dependencies section and android section

    0 讨论(0)
提交回复
热议问题