3
votes

If I'm trying to update an Cordova Android project.

The following error occurs after updating the platform version:

Gradle 'android' project refresh failed

Error:Could not find method signingConfig() for arguments [SigningConfig_Decorated{name=configFlavor1, storeFile=C:\myApp\project\platforms\android\app\keystore\flavor1.keystore, storePassword=mysecretpw, keyAlias=flavor1, keyPassword=mysecretpw, storeType=C:\myApp\project\platforms\android\app\keystore\flavor1.keystore, v1SigningEnabled=true, v2SigningEnabled=true}, null] on ProductFlavor_Decorated{name=flavor1, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=26, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.myapp.flavor1, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.

my build.gradle looks as follows:

android {
    signingConfigs {            
        configFlavor1 {
            keyAlias 'flavor1'
            keyPassword 'mysecretpw'
            storeFile file('./keystore/flavor1.keystore')
            storePassword 'mysecretpw'
        }
        configFlavor2 {
            keyAlias 'flavor2'
            keyPassword 'mysecretpw'
            storeFile file('./keystore/flavor2.keystore')
            storePassword 'mysecretpw'
        }
    }
    sourceSets {
        main {
            manifest.srcFile './src/main/AndroidManifest.xml'
            java.srcDirs = ['.src/main/java']
            resources.srcDirs = ['.src/main/java']
            aidl.srcDirs = ['.src/main/java']
            renderscript.srcDirs = ['.src/main/java']
            res.srcDirs = ['.src/main/res/myapp']
            assets.srcDirs = ['.src/main/assets']
            jniLibs.srcDirs = ['./src/main/libs']
        }

        flavor2 {
            res.srcDirs = ['res/flavor2']
        }
    }
    defaultConfig {
        versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
        applicationId 'com.myapp.flavor1'
        minSdkVersion 16
        targetSdkVersion 26
    }

    lintOptions {
      abortOnError false;
    }
    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion
    flavorDimensions "flavor1", "flavro2"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    productFlavors {
        flavor1 {
            minSdkVersion 16
            targetSdkVersion 26
            applicationId 'com.myapp.flavor1'
            signingConfig signingConfigs.configFlavor1,
            dimension "flavor1"
            }

        flavor2 {
            minSdkVersion 16
            targetSdkVersion 26
            applicationId 'com.myapp.flavor2'
            signingConfig signingConfigs.configFlavor2,
            dimension "flavor2"
        }
        }
        buildTypes {
            release {
                zipAlignEnabled true
                signingConfig signingConfigs.release
            }
        }
        addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
}

The signing config (key/pw) works as expected on the old version. One thing that I changed on the new build.gradle is adding flavorDimensions (Android Studio requested to define them).

I have no idea why the signing config is marked as invalid.

Any help is appreciated - thanks in advance!

2
Is there no line number that goes with the error?Peter Ledbrook

2 Answers

3
votes

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

            }


}
0
votes

error occured on

signingConfig signingConfigs.configFlavor1, dimension "flavor1"

where comma was used :x