2016-10-21 3 views
1

Я перед этой ошибки в течение длительного времени ..Android Построить 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 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' 
//} 

И мой module/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') 
} 

Может ли кто-нибудь направить меня в правильном направлении ..

И до этого я получил аналогичную ошибку для «метода андроида».

Я много гулял, но не пользовался большим спросом. Заранее спасибо

+0

Вы пытались обновить библиотеку GSON до последней версии с помощью: 'compile 'com.google.code.gson: gson: 2.7''? –

+0

Yea .. не сработал .. – Kshitij

ответ

0

Кажется, что в вашем файле есть проблема.

Структура должна быть:

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

    compileSdkVersion 23 
    buildToolsVersion "23.0.0" 

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

repositories { .. } 

dependencies { 
    //.. 
} 

Перемещение repositories блока вне android блока.

+0

Yea я сделал это .. такой же проблема снова .. – Kshitij