7

I have reviewed a number of posts on this topic,

for starters. But I still cannot get past the Gradle error Error:(69, 0) Could not find method storeFile() for arguments [/path/to/my.keystore] on line 69:

storeFile file(keystoreProperties['storeFile'])

in the module gradle build file - contents of my module gradle.build file:

apply plugin: 'com.android.application'
apply plugin: 'signing'

android {

    ...

    buildTypes {

        ...

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            def keystorePropertiesFile = rootProject.file("keystore.properties");
            def keystoreProperties = new Properties()
            keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']

        }

        ...

    }

    ...

}

...

where I load the keystore.properties file (located in project root), which contains:

storeFile=/path/to/my.keystore
storePassword=storepwd
keyPassword=keypwd
keyAlias=keyalias

As you can see, I have a file constructor in the storeFile reference in the gradle.build file and a path to the keystore in the properties file.

Where is the mistake, or what am I missing, not understanding?

Reference

  • Android Studio 2.3.3
  • Gradle version 4.1
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

1 Answers1

21

You have to add this DSL in the signing block not in the buildTypes block.

signingConfigs {
        release {
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']

        }
    }
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841