Android Build Gradle给出complie()错误

Android Build Gradle给出complie()错误,android,gradle,android-gradle-plugin,build.gradle,Android,Gradle,Android Gradle Plugin,Build.gradle,我已经面临这个错误很久了 Error:(24, 0) Could not find method compile() for arguments [com.google.code.gson:gson:2.3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 我的根build.gradle是 // Top-level build fi

我已经面临这个错误很久了

Error:(24, 0) Could not find method compile() for arguments   
   [com.google.code.gson:gson:2.3] on object of type  
   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我的根
build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}



//apply plugin: 'com.android.application'  
//  
//android {  
//    compileSdkVersion 23  
//    buildToolsVersion '23.0.0'  
//}  
我的
模块/build.gradle

apply plugin: 'com.android.application'
android {

    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.example.zumoappname"
        minSdkVersion 7
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
       release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
    }

    repositories {
       flatDir {
          dirs 'aars'
      }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.guava:guava:18.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
    compile (group: 'com.microsoft.azure', name: 'azure-notifications-handler', version: '1.0.1', ext: 'jar')
}
谁能告诉我正确的方向吗

在这之前,我收到了一个类似的“android方法”错误

我在谷歌上搜索了很多,但没有多大用处。
提前感谢:)

您的文件似乎有问题

结构应为:

apply plugin: 'com.android.application'
android {

    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig { ... }
    buildTypes {
       release {...}
    }   
}

repositories { .. }

dependencies {
   //..
}

repositories
块移到
android
块之外。

您的文件似乎有一些问题

结构应为:

apply plugin: 'com.android.application'
android {

    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig { ... }
    buildTypes {
       release {...}
    }   
}

repositories { .. }

dependencies {
   //..
}

存储库
块移到
android
块之外。

您是否尝试过使用
compile'com.google.code.GSON:GSON:2.7'
将GSON库更新到最新版本?是。。不起作用..您是否尝试使用:
compile'com.google.code.GSON:GSON:2.7'
将GSON库更新到最新版本?是。。不起作用。。