HMCFletch
HMCFletch

Reputation: 1076

Build an unsigned apk for Amazon and a signed apk for Google

I have two build types (debug and release) and two product flavors (google and amazon) and I need to be able to specify all variants to be signed with signingConfigs.release except the amazonRelease variant which needs to be signed with signingConfigs.unsigned.

I'm not sure how to target a specific build variant (i.e., amazonRelease) so I can set its signingConfig.

This is what I currently have in my build.gradle:

android {

  ...

  signingConfigs {
    release {
      storeFile ...;
      keyAlias ...;
      storePassword ...;
      keyPassword ...;
    }

    unsigned {
      keyAlias "";
      storePassword "";
      keyPassword "";
    }
  }

  buildTypes {
    debug {
      versionNameSuffix = "-DEBUG"
    }

    release {
      signingConfig signingConfigs.release;
    }
  }

  flavorGroups "storeFront"

  productFlavors {
    google {
      flavorGroup "storeFront"
    }

    amazon {
      flavorGroup "storeFront"
    }
  }
}

Upvotes: 3

Views: 900

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

Quoting the documentation:

There are cases where a setting is settable on both the Build Type and the Product Flavor. In this case, it’s is on a case by case basis.

For instance, signingConfig is one of these properties.

This enables either having all release packages share the same SigningConfig, by setting android.buildTypes.release.signingConfig, or have each release package use their own SigningConfig by setting each android.productFlavors.*.signingConfig objects separately.

So, I'd try removing the release signingConfig and adding signingConfig properties to google and amazon. If I understand the docs correctly, the debug signingConfig will trump the google and amazon signingConfig properties for debug builds, and release builds will use the ones defined on the flavors.

Upvotes: 2

Related Questions