Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.

后端 未结 5 739
时光取名叫无心
时光取名叫无心 2020-11-28 08:36

I am getting the following build error when I try and sync my project:

Error:(9, 0) Gradle DSL method not found: \'compile()\'
Possible causes:The project \         


        
相关标签:
5条回答
  • Hi everyone for me it was a "couple days consuming job" to make my app run in Android Studio (I migrated from Eclipse and had this problem too ) . Finally I found that very simple way of it .

    1. Create libs folder under src/main/java/ it is App/java/libs in left pane .
    2. Copy and paste all your external jars into here.
    3. Goto left pane and right click on your App then click Open Module Settings
    4. Then Project Structure window will appear .
    5. Then move to Dependencies tab . Final Step : Add all your jars located in App/java/libs (You will find them in src/main/java/libs) one by one .

    That is all Enjoy it.

    0 讨论(0)
  • 2020-11-28 08:57

    Declare dependencies in Module's build.gradle file, not in AlexTest's build.gradle file

    0 讨论(0)
  • 2020-11-28 09:03

    Just add foolwoing statement in your dependencies

    apply plugin: 'jetty'

    0 讨论(0)
  • 2020-11-28 09:12

    I have tried applying every single gradle plugin they link me to in that link on the bottom, yet same issue, so I conclude that the first error is the cause.

    Correct.

    Here is the build.gradle file for AlexTest (the project directory):

    You will notice that this file contains a code comment:

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    

    Remove the compile 'com.google.android.gms:play-services:6.1.11' line from that file. Leave the compile 'com.google.android.gms:play-services:6.1.+' that you have in the other build.gradle file.

    The dependencies closure in buildscript is for Gradle plugins only. The top-level dependencies closure, found in the module's build.gradle file, is for application dependencies.

    0 讨论(0)
  • 2020-11-28 09:13

    Saw reports that the problem occurred for other reasons, but this solved for me.

    If you carry out any changes in the Project Structure (Android Studio) and press OK, Gradle will be synchronized, but this type of synchronization, if the dependency block has something like:

    This block will stay this way after synchronization:

    One way to solve the problem is to insert a line break to stay as it was before the synchronization or put a semi-colon between the two statements.

    I hope it helps.

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