将Simperium模块添加到Project会导致找不到Gradle DSL方法:'gitVersion()'错误

时间:2015-11-05 10:38:45

标签: android android-gradle build.gradle simperium android-studio-import

在我的应用程序中添加Simperium模块应用程序代码后出现错误。它给了我Gradle sync failed: Gradle DSL method not found: 'gitVersion()'错误。我该如何解决?

build.gradle code here:

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.1"

    defaultConfig {
        applicationId "sdn.com.sd"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-annotations:23.0.1'
    compile 'com.android.support:support-v13:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile project(':SDUtils')
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile project(':SDAnalytics')
    compile project(':SDEditor')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
    compile files('libs/gcm.jar')
    compile project(':SDNetworking')
    compile project(':PassCode')
    compile files('libs/eventbus-3.0.0-beta1.jar')
    compile project(':Simperium')
}

Gradle Sync消息输出:

Error:(13, 0) Gradle DSL method not found: 'gitVersion()'
Possible causes:<ul><li>The project 'SD' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您正在项目中添加模块(正如您在评论中所述)

  

您可以在此链接看到Simperium模块项目。 github.com/Simperium/simperium-android我只是在项目中添加了这个项目作为模块

Gradle正在尝试处理 Simperium模块中的build.gradle

https://github.com/Simperium/simperium-android/blob/develop/build.gradle

在这个文件中,有一些函数在Simperium项目的root/build.gradle中定义。

def gitHash() {..}
def gitDescribe() {..}
def gitVersion(){..}

您必须在您的顶级 build.gradle文件中复制这些功能

root
|--app
|----build.gradle
|--build.gradle   <- here
|--settings.gradle