How to fix the error arising while using flutter build appbundle: No signature of method?

196

I haven't found any right documentation to explain the issue but what I tried is commenting that only the android block and I found the issue only in these codes,

kotlinOptions {
        jvmTarget = '1.8'
}
sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
}

After commenting these lines I solved the issue of creating the app bundle of a flutter app.

Here is the output

flutter build appbundle                                                             
Running "flutter pub get" in app...                        Xms
💪 Building with sound null safety 💪
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Removed unused resources: Binary resource data reduced from XKB to XKB: Removed X%
Running Gradle task 'bundleRelease'...                             Xs
✓ Built build\app\outputs\bundle\release\app-release.aab (X.XMB).

I think this would help someone : )

Share:
196
Author by

Spsnamta

Updated on January 02, 2023

Comments

  • Spsnamta 2 minutes

    I was getting the error while I was trying to build an app bundle of a flutter app in a release mode but while I run the command flutter build appbundle, this error just showed up.

    💪 Building with sound null safety 💪
    FAILURE: Build failed with an exception.
    * Where:
    Build file '<PROJECT_DIR>\android\app\build.gradle' line: 36
    A problem occurred evaluating project ':app'.
    > No signature of method: build_djjv0udzo4jemkigdf7i4cm25.android() is applicable for argument types: (build_djjv0udzo4jemkigdf7i4cm25$_run_closure2) values: [[email protected]]
    * 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.
    BUILD FAILED in 2s
    Running Gradle task 'bundleRelease'...                              4.5s
    Gradle task bundleRelease failed with exit code 1
    

    And here is error part of android/app/build.gradle file.

    android {
        compileSdkVersion flutter.compileSdkVersion
        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.example.app"
            minSdkVersion XX 
            targetSdkVersion flutter.targetSdkVersion
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
        }
        signingConfigs {
            release{
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']): null
                storePassword keystoreProperties['storePassword']
            }
        }
        buildTypes{
            release{
                signingConfig signingConfigs.release
            }
        }
    }
    

    After trying a lot and following many articles I was not able to solve it. here are some of the similar problems which I checked.

    problem_1