0

I'm signing a keystore to upload a flutter app to google play for the first time, and having trouble finding a keystore. Any idea what could be going wrong?

Specifically, I'm getting the following error:

  • Where: Build file '/Users/charl/Documents/Development/flutter_apps/twitter_drafts/android/app/build.gradle' line: 64

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

Could not find method keyAlias() for arguments [upload] on BuildType$AgpDecorated_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=true, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[/Users/charl/Documents/Development/flutter_apps/twitter_drafts/build/app/intermediates/default_proguard_files/global/proguard-android.txt-7.3.0, /Users/charl/Documents/Development/SDKs/flutter/packages/flutter_tools/gradle/flutter_proguard_rules.pro, /Users/charl/Documents/Development/flutter_apps/twitter_drafts/android/app/proguard-rules.pro], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType$AgpDecorated.

  • 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.

Here is my Build Gradle file: Build Gradle File

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

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }

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.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    namespace "com.pagefamdesigns.application_name"
    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 {
        applicationId "com.pagefamdesigns.application_name"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode 1
        versionName flutterVersionName
    }

    buildTypes {
        release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
    }
}

And here's my Key.properties file:

storePassword=[[password is here]]
keyPassword=[[password is here]]
keyAlias=upload
storeFile=/Users/charl/upload-keystore.jks

(There is a file at that location)

Screenshot of my File Structure

2
  • May be you misspelled the alias Commented Jul 8, 2023 at 13:32
  • Did you see that somewhere in the provided files? I'm not seeing any misspellings. Commented Jul 8, 2023 at 19:51

1 Answer 1

5

Looks like the issue was that I had copied the keystore settings into the buildTypes section within the android section of the build.gradle file. I was supposed to have something else in the buildTypes section, and include the keystore stuff in the signingConfigs section.

Bad

android {

... Some stuff

    buildTypes {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
}

Good

android {

... Some stuff

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.