

You have 2 different build.gradle (sometimes more depending on you)
Only one of them is your app's gradle, then the other one is project's gradle.
If you put your dependencies project's gradle you can get error : Gradle DSL method not found: 'compile()'
Put your dependencies in app's build.gradle then it will work.