2017-05-17 116 views
0

我的build.gradle文件存在這個非常令人沮喪的問題。當我決定將新庫添加到我的項目時:「Deter-master」lib。Android gradle錯誤:(69,0)未找到Gradle DSL方法:'compile()'

這是錯誤消息:

Gradle sync failed: Could not find method compile() for arguments [com.android.support:appcompat-v7:25.0.0] on DefaultExternalModuleDependency{group='com.android.support', name='support-v13', version='25.0.0', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency. Consult IDE log for more details (Help | Show Log)

下面你可以看到所有gradle這個文件:

apply plugin: 'com.android.application' 

ext { 
    libraries = [ 
      support : "25.0.0", 
      location: "9.8.0" 
    ] 
} 
def config = project.ext.libraries 


repositories { 
    mavenCentral() 
    mavenLocal() 
    flatDir { 
     dirs 'libs' 
    } 
    maven { url 'https://maven.fabric.io/public' } 
} 
repositories { 
    maven { 
     url 'https://dl.bintray.com/blipinsk/maven/' 
    } 
} 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.0" 

    defaultConfig { 
     applicationId "com.airnauts.kaktus" 
     minSdkVersion 19 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
    } 
    signingConfigs { 
     debug { 
      storeFile file("../social_keystore.jks") 
      storePassword "social" 
      keyAlias "social" 
      keyPassword "social" 
     } 
     release { 
      storeFile file("../social_keystore.jks") 
      storePassword "social" 
      keyAlias "social" 
      keyPassword "social" 
     } 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

android { 
    packagingOptions { 
     exclude 'LICENSE.txt' 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile(name: 'toolkit', ext: 'aar') 
    compile "com.android.support:support-v13:${config.support}" compile "com.android.support:appcompat-v7:${config.support}" compile "com.android.support:support-v4:${config.support}" compile "com.android.support:recyclerview-v7:${config.support}" compile "com.android.support:design:${config.support}" compile "com.android.support:cardview-v7:${config.support}" compile "com.android.support:percent:${config.support}" compile "com.google.android.gms:play-services-location:${config.location}" compile "com.google.android.gms:play-services-maps:${config.location}" 
    //blipinsk 
    compile 'com.firebaseui:firebase-ui-auth:0.6.2' 
    compile 'com.bartoszlipinski:viewpropertyobjectanimator:1.2.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.jakewharton:butterknife:7.0.0' 
    compile 'com.makeramen:roundedimageview:2.2.0' 
    compile 'de.greenrobot:eventbus:2.4.0' 
    compile 'uk.co.chrisjenx:calligraphy:2.1.0' 
    compile 'com.facebook.android:facebook-android-sdk:4.7.0' 
    compile 'me.kaelaela:verticalviewpager:[email protected]' 
    compile 'com.google.code.gson:gson:2.2.4' 
    compile 'com.google.firebase:firebase-auth:9.8.0' 
    compile 'com.firebaseui:firebase-ui:1.0.0' 
    compile 'com.android.support:support-v4:25.1.0' 
    compile 'com.karumi:dexter:4.1.0' 
    compile project('Libraries:Dexter-master') 
} 

apply plugin: 'com.google.gms.google-services' 

另一部分:

// 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.2' 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     flatDir { 
      dirs 'libs' 
     } 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

,最後一個:

include ':app' 
include ':app:Libraries:Dexter-master' 

回答

1

嘗試更換:

compile "com.android.support:support-v13:${config.support}" compile "com.android.support:appcompat-v7:${config.support}" compile "com.android.support:support-v4:${config.support}" compile "com.android.support:recyclerview-v7:${config.support}" compile "com.android.support:design:${config.support}" compile "com.android.support:cardview-v7:${config.support}" compile "com.android.support:percent:${config.support}" compile "com.google.android.gms:play-services-location:${config.location}" compile "com.google.android.gms:play-services-maps:${config.location}" 

有:

compile "com.android.support:support-v13:${config.support}" 
compile "com.android.support:appcompat-v7:${config.support}" 
compile "com.android.support:support-v4:${config.support}" 
compile "com.android.support:recyclerview-v7:${config.support}" 
compile "com.android.support:design:${config.support}" 
compile "com.android.support:cardview-v7:${config.support}" 
compile "com.android.support:percent:${config.support}" 
compile "com.google.android.gms:play-services-location:${config.location}" 
compile "com.google.android.gms:play-services-maps:${config.location}" 
+0

十分感謝!它沒有解決gradle中的所有問題,但它幫助我專注於重要的部分。 Gradle成功建造! –

+0

感謝它爲我工作。 – Nilesh

相關問題