50

I try signing my Application like this link. I write my signingConfigs settings but I get "Could not find property" error.

This my build.gradle

apply plugin: 'android'

    android {
        compileSdkVersion 19
        buildToolsVersion '19.0.3'
        defaultConfig {
            minSdkVersion 11
            targetSdkVersion 19
            versionCode 1
            versionName "Andy Warhol"
        }
        buildTypes {
            debug {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                debuggable false
                jniDebugBuild false
                signingConfig signingConfigs.myconfig
            }
            release {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                debuggable false
                jniDebugBuild false
            }
        }
        signingConfigs {
            myconfig {
                keyAlias 'xxx'
                keyPassword 'xxx'
                storeFile file('xxx')
                storePassword 'xxx'
            }
        }
    }

    dependencies {
        compile 'com.android.support:appcompat-v7:+'
        compile 'com.google.android.gms:play-services:4.0.30'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/picasso-2.2.0.jar')
        compile files('libs/acra-4.5.0.jar')
        compile files('libs/libGoogleAnalyticsServices.jar')
    }

This is my error

Gradle 'BulentTirasMobileApp' project refresh failed: Could not find property 'myconfig' on SigningConfig container.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Olkunmustafa
  • 3,103
  • 9
  • 42
  • 55

2 Answers2

140

Move your signingConfigs block to appear before your buildTypes block:

    signingConfigs {
        myconfig {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('xxx')
            storePassword 'xxx'
        }
    }
    buildTypes {
        debug {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
            jniDebugBuild false
            signingConfig signingConfigs.myconfig
        }
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
            jniDebugBuild false
        }
    }

You need to define the configuration before you can use it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

In my case, moving 'signingConfigs' manually above 'buildTypes' didn't work, but produced a different error. So, what I did is delete 'signingConfigs' section altogether and generated 'signingConfigs' via 'File'>'Project Structure' -> 'Signing Configs'.

'SigningConfigs' in 'Project Structure'

It automatically generated 'signingConfigs' and errors disappeared. It placed 'signingConfigs' like in a picture below

build.gradle(app)

yura910721
  • 23
  • 4