Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

signingConfigs tag giving me a Lint error in build.gradle after upgrading to v22

I've had the following code in my build.gradle (app) file for a while:

signingConfigs {
    release {
        storeFile file("D:\\Android\\keystore\\myApp.jks")
        storePassword "myStorePw"
        keyAlias "myKeyAlias"
        keyPassword "MyKeyPw"
    }
}

I've just upgraded to targetSdkVersion=22, which meant upgrading SDKs and build tools to 22 as well. Now that whole section is highlighted in yellow in Android Studio (141.1793788) with the message:

'signingConfigs' cannot be applied to '(groovy.land.Closure<com.android.build.gradle.internal.dsl.SigningConfig>)'

Has there been a change in v22 that I need to know about? I can't find documentation.

like image 424
Scott Avatar asked Mar 20 '15 15:03

Scott


2 Answers

Please try to move your signingConfigs section higher, just below: compileSdkVersion and buildToolsVersion. Example below:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    signingConfigs {
        release {
            storeFile file("D:\\Android\\keystore\\myApp.jks")
            storePassword "myStorePw"
            keyAlias "myKeyAlias"
            keyPassword "MyKeyPw"
       }
    }
}
like image 160
questioner Avatar answered Nov 13 '22 20:11

questioner


As @GDanger asked for the reason; So the reason is simple. When you define a variable in gradle script, keep that in mind, It should not be used before its definition.

I am pretty much sure that OP has defined the signingConfigs below buildType config. And because of that he is getting that warning message.

Let's do an experiment to understand; write below code in your gradle script:

def A = B;
def B = "I am test."

You'll see this error when you syn with gradle:

Error:(3, 0) Could not find property 'B' on project ':app'.
<a href="openFile">Open File</a>

But when you define it like this:

def B = "I am test."
def A = B;

You'll not get any error. So I am sure trying this small experiment would make you understand that how compiling in gradle script works. Hope this will help. :)

like image 7
TheLittleNaruto Avatar answered Nov 13 '22 20:11

TheLittleNaruto