2016-11-16 28 views
0

我試圖運行我的應用程序,並得到這個錯誤,請幫助我。錯誤:(22,0)找不到方法android()參數

// 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.0' 
     classpath 'com.google.gms:google-services:3.0.0' 
     // 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 
} 

android { 
    signingConfigs { 
     config { 
     } 
    } 
    buildToolsVersion '24.0.2' 
    compileSdkVersion 24 
    buildTypes { 
     buildType { 
      signingConfig signingConfigs.config 
     } 
    } 
} 
dependencies { 
} 

錯誤:

Error:(22, 0) Could not find method android() for arguments [[email protected]] on root project 'Recipe App' of type org.gradle.api.Project.

回答

0
// 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.3.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 
} 

android { 
    compileSdkVersion 25 
    buildToolsVersion '25.0.2' 
    dexOptions { 
     incremental true 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 
} 
dependencies { 
    compile files('app/libs/junit-4.12-JavaDoc.jar') 
} 
apply plugin: 'maven'`enter code here` 
+1

歡迎StackOverflow上,這僅僅是一個代碼。你能否介紹一下這一點 – IsuruAb

0

我面臨同樣的問題,解決它BY:

  1. 打開 '的build.gradle' 文件,你會發現下面可能是你的comiple版本是不同的,但我不想顯示文件結構。 的Android { compileSdkVersion 25 buildToolsVersion '25 .0.2' } 依賴{} 的 錯誤發生,因爲類似Android的聲明是在其他的build.gradle文件。因此請刪除android和依賴項。

更多細節here

相關問題