Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error - Could not find method storeFile() for arguments /path/to/storefile

I have reviewed a number of posts on this topic,

  • Gradle DSL method not found: storeFile()
  • Sign APK without putting keystore info in build.gradle

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
like image 425
Roy Hinkley Avatar asked Oct 13 '17 19:10

Roy Hinkley


1 Answers

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']

        }
    }
like image 66
Gabriele Mariotti Avatar answered Sep 18 '22 21:09

Gabriele Mariotti