Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio throws "No signature of method" error, pointing to build.gradle:app

I got this error after trying to run a Kotlin application through Android Studio:

A problem occurred evaluating project ':app'.
> No signature of method: build_4blexxmb1pl0fsds689m8rkwz.android() is applicable for argument types: (build_4blexxmb1pl0fsds689m8rkwz$_run_closure1) values: [build_4blexxmb1pl0fsds689m8rkwz$_run_closure1@220b09f3]

The error points me to this section of the build.gradle:app file (specifically, the line with android {):

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    buildFeatures {
        viewBinding = true

        defaultConfig {
            applicationId "com.example.bitfighter"
            minSdkVersion 19
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"

            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }

        buildReleases {
            viewBinding = true
        }

What does this error message mean, and what can I change to fix the issue?

like image 479
Miles Morales Avatar asked Sep 15 '25 10:09

Miles Morales


1 Answers

Try to structure the code like this

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.bitfighter"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        viewBinding = true
    }

The defaultConfig should always only be in the android clause and not inside the buildFeatures. Other than that, you don't need a buildReleases clause when you already have added a buildFeatures clause.

like image 142
Akshat Tiwari Avatar answered Sep 17 '25 00:09

Akshat Tiwari