Gradle build:找不到参数的signedConfig()方法

时间:2018-04-10 12:01:07

标签: java android android-studio gradle

如果我正在尝试更新Cordova Android项目。

更新平台版本后发生以下错误:

  

Gradle' android'项目刷新失败

     

错误:找不到参数的方法signingConfig()   [SigningConfig_Decorated {名称= configFlavor1,   storeFile = C:\对myApp \项目\平台\机器人\程序\密钥库\ flavor1.keystore,   storePassword = mysecretpw,keyAlias = flavor1,keyPassword = mysecretpw,   的storetype = C:\对myApp \项目\平台\机器人\程序\密钥库\ 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}   com.android.build.gradle.internal.dsl.ProductFlavor。

我的 build.gradle 如下所示:

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)
}

签名配置(key / pw)在旧版本上按预期工作。 我在新build.gradle上更改的一件事是添加 flavorDimensions (Android Studio请求定义它们)。

我不知道为什么签名配置被标记为无效。

感谢任何帮助 - 提前感谢!

2 个答案:

答案 0 :(得分:3)

您必须在签名块中添加此DSL,而不是在buildTypes块中添加。

<button class="element-center" id="btn" type="button">This Button</button>

答案 1 :(得分:0)

发生

错误

signingConfig signingConfigs.configFlavor1, dimension "flavor1"

使用逗号:x