androidandroid-gradle-pluginbuild.gradlesimperiumandroid-studio-import

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


I get an error after adding a Simperium Module Application code to my application. It gives me Gradle sync failed: Gradle DSL method not found: 'gitVersion()' error. How can I fix it?

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 message output:

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>

Thanks in advance for your helps.


Solution

  • You are adding a module in your project (as you've explained in your comment)

    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 is trying to process the build.gradle inside the Simperium module.

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

    Inside this file there are some functions defined in the root/build.gradle of the Simperium-project.

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

    You have to copy these functions inside your top-level build.gradle file.

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