将 Simperium 模块添加到项目中会出现 Gradle DSL 方法未找到:'gitVersion()' 错误

Adding Simperium Module to Project gives Gradle DSL method not found: 'gitVersion()' error

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

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.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 同步消息输出:

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>

在此先感谢您的帮助。

您正在项目中添加一个模块(正如您在评论中所解释的那样)

you can have the look of the Simperium module project at this link. github.com/Simperium/simperium-android I had simply added this project as a module in my application

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