0

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>

提前感谢您的帮助。

4

1 回答 1

1

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

您可以在此链接中查看 Simperium 模块项目。github.com/Simperium/simperium-android 我只是将此项目作为模块添加到我的应用程序中

Gradle 正在尝试处理Simperium 模块build.gradle内部。

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

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

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

您必须将这些函数复制您的顶级 build.gradle文件中。

root
|--app
|----build.gradle
|--build.gradle   <- here
|--settings.gradle
于 2015-11-05T12:38:59.520 回答