Home > OS >  A problem occurred evaluating project ':app' . No signature of method
A problem occurred evaluating project ':app' . No signature of method

Time:10-26

Recently, I studied using firebase in a flutter project. I followed the step but also got an error. I searched and guess it is a app\build.gradle getting a problem. But also didn't know what the problem is.

No signature of method: build_5viubdggwtiixi0imz59oppqn.android() is applicable for argument types: (build_5viubdggwtiixi0imz59oppqn$_run_closure2) values: [build_5viubdggwtiixi0imz59oppqn$_run_closure2@71088475] Here are the "relevant codes and error:

Error:

FAILURE: Build failed with an exception.

* Where:
Build file 'E:\firebase\android\app\build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_5viubdggwtiixi0imz59oppqn.android() is applicable for argument types: (build_5viubdggwtiixi0imz59oppqn$_run_closure2) values: [build_5viubdggwtiixi0imz59oppqn$_run_closure2@71088475]

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

Code:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs  = 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.getx.app.db.firebaseApp"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        MultiDexEnable true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
}

CodePudding user response:

@lousea, We get such kind of error when we use any undefined attribute in the gradle file.

In your case, in the default config, you have misspelled the multidex attribute. Just change MultiDexEnable to multiDexEnabled then it will work properly. or just replace the defaultConfig from below

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.getx.app.db.firebaseApp"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }
  • Related