Getting Error “Gradle DSL method not found: 'compile()'” when Syncing Build.Gradle

后端 未结 10 815
后悔当初
后悔当初 2020-11-30 09:42

\"Error\"project

相关标签:
10条回答
  • 2020-11-30 10:34

    Just delete the method.

    //DELETE THIS LINES:
    android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'
    }
    

    Try to compile again. It should work now.

    Source : https://medium.com/@marcuspereira/solving-the-gradle-dsl-method-not-found-android-in-android-studio-6e5ab499bd3#.u1lxecq41

    0 讨论(0)
  • 2020-11-30 10:36

    Hi everyone for me it was a "couple days consuming job" to make my app run in Android Studio . 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 .
    6. 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-30 10:37

    This worked for me:

    1. Exit Android Studio.
    2. Remove <home folder>/.gradle folder.
    3. Relaunch Android studio and let it load all gradle modules again.

    P.S.: Mine was a fresh project so I removed the project as well and created a new one, so there were no old gradle references from the project

    0 讨论(0)
  • 2020-11-30 10:39

    In my case, there are 2 build.gradle file in my project (it auto create by android studio when create new project)

    Just move the compile line to another one is solve my problem

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