简体   繁体   中英

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 (ie, 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"
    }
  }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM