groovy.lang.MissingMethodException: No signature of method error in java

Viewed 2362

I was building a project at android studio with java, and I got this error while syncing gradle.

Build file 'C:\Android_Studio_Projects\app\build.gradle' line: 5

A problem occurred evaluating project ':app'.

No signature of method: build_8apajpm3hvj7yb70k4a4pygjn.android() is applicable for argument types: (build_8apajpm3hvj7yb70k4a4pygjn$_run_closure1) values: [build_8apajpm3hvj7yb70k4a4pygjn$_run_closure1@591bdbf1]

Here is the code.

android {
    compileSdk 31
    databinding {
        enabled true
    }
    defaultConfig {
        applicationId "com.example.rssi"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

*It's my first time asking here, so I don't know well about how to ask. If there are things I should add, please tell me.

1 Answers

I tried to compile your code and noticed an error. Remove this code:

databinding {
    enabled true
}

And add at the bottom of the android block:

buildFeatures {
    dataBinding true
}
Related