0
votes

Actually I get a very strange error when I try to run a Flutter build for Android. First of all I want to show you the error. After that I show you the Flutter doctor result and specific code parts of my project.

Error after running android project with flutter run

  • What went wrong: A problem occurred evaluating project ':app'.

Could not find method versionName() for arguments [1.0.0, null] on DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=18, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=8, versionName=null, applicationId=de.danielederosa.virtualguestbook, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig.

  • 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 6s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

gradle.wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

pubspec.yaml

version: 1.0.0+8

It's interesting that it shows versionName=null, also if I overwrite the variable like this:

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "de.danielederosa.virtualguestbook"
        minSdkVersion 18
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName '1.0.0',
        multiDexEnabled true
    }

Do you have any idea what could be the issue? Maybe some incompatibility with the gradle versions?

2

2 Answers

0
votes

Make it to default settings to see if it work:

This is my default flutter build.gradle (app)

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

and

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.teddichiiwa.example"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
0
votes

I think you made a mistake on the line "versionName '1.0.0'," there is a comma that should not be there. Change the line to versionName '1.0.0' I hope I have been helpful.