2017-04-09 68 views
-1

由於以下Gradle錯誤,無法運行Android應用程序。未找到Android Gradle方法:'compile()'

Gradle DSL method not found : 'compile()' 
Possible Causes : 
       The project XXXX may be using a version of Gradle that does not contain the method . 

The build file may be missing a Gradle Plugin . 

請幫助如何解決這個問題。

編輯:

文件的build.gradle

PFB我的build.gradle從項目文件,大部分文件似乎依賴關係,但爲什麼問題無法解決同樣以復加。

buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 

repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 


android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "xxxxxxxx" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 2 
     versionName "1.2" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

android { 
    useLibrary 'org.apache.http.legacy' 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'me.zhanghai.android.materialprogressbar:library:1.1.6' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.sa90.materialarcmenu:library:1.4.1' 
    compile files('libs/jxl.jar') 
    compile 'com.google.code.gson:gson:2.2.4' 
    compile 'com.github.clans:fab:1.6.4' 
    compile 'com.android.support:cardview-v7:23.4.0' 
    compile files('libs/acra-4.6.1.jar') 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'commons-codec:commons-codec:1.10' 
    compile "com.android.support:support-v4:+" 
    compile 'com.squareup.picasso:picasso:2.3.2' 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.daimajia.slider:library:[email protected]' 
} 
+1

請編輯您的問題,並提供[MCVE。這將包括觸發此錯誤消息的'build.gradle'文件。 – CommonsWare

+0

頂級build.gradk明確表示不要將您的應用程序依賴項放入其中 –

回答

0

您在項目build.gradle中有依賴項,請確保將它放在app/build.gradle中。

例如,在應用程序/的build.gradle

dependencies { 
    compile 'com.android.support:appcompat-v7:25.2.0' 
} 
相關問題