Gradle로 제품 버전 서명
내 프로젝트를 gradle로 마이그레이션하는 데 지쳐 있습니다. 내 프로젝트 중 하나에는 여러 제품 버전이 있으며 각 signingConfig
버전은 릴리스 버전에서 서로 다른 버전 으로 서명되어야합니다 . 그래서 이것은 내가 지금까지 시도한 것입니다.
buildscript {
...
}
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '17'
signingConfigs {
flavor1 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor1"
keyPassword "secretFlavor1"
}
flavor2 {
storeFile file("keystore")
storePassword "secret"
keyAlias "aliasForFlavor2"
keyPassword "secretFlavor2"
}
}
productFlavors {
flavor1 {
signingConfig signingConfigs.flavor1
}
flavor1 {
signingConfig signingConfigs.flavor2
}
}
}
dependencies {
...
}
내가 실행할 때 gradle build
내가 얻을 groovy.lang.MissingFieldException
다음과 같은 오류 메시지가 :
No such field: signingConfigs for class: com.android.build.gradle.internal.dsl.GroupableProductFlavorFactory
따라서 productFlavors
Gradle 스크립트 의 . * 부분이 코드 서명 구성을 배치하기에 적합한 위치가 아니라고 가정합니다 .
당 사용자 가이드 , 맛에 대한 signingConfigs이 지원됩니다.
여기서 문제는 signingConfigs 개체의 범위와 관련이 있습니다. 방금 productFlavors
블록 내부의 변수에 할당 했지만 flavor1
문제를 해결하기 위해 플레이버 블록 외부에 할당했습니다 .
productFlavors {
def flavor1SigningVariable = signingConfigs.flavor1
flavor1 {
...
signingConfig flavor1SigningVariable
...
}
You can declare signing config
for each flavor
in buildType
. Here is my gradle file for release signing flavors with different keystores.
android {
signingConfigs {
configFirst {
keyAlias 'alias'
keyPassword 'password'
storeFile file('first.keystore')
storePassword 'password'
}
configSecond {
keyAlias 'alias'
keyPassword 'password'
storeFile file('second.keystore')
storePassword 'password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
productFlavors{
flavor1 {
applicationId "com.test.firstapp"
}
flavor2 {
applicationId "com.test.secondapp"
}
}
buildTypes {
release {
productFlavors.flavor1.signingConfig signingConfigs.configFirst
productFlavors.flavor2.signingConfig signingConfigs.configSecond
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
buildTypes
block should be placed after productFlavors
block, I mean order is important.
The gradle plugin for android only supports signing per build type, not per flavor. The reason for this is that any given variant (build type + flavors) can only be signed by one key, but can be a combination of several flavor groups. For example your flavor groups could be cpu (x86/arm) and version (free/paid), that's four different variants right there.
The solution you're looking for is to create separate build types for your different release versions. For example, your build types might be debug
, release
, release-beta
, like this:
...
android {
...
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
release-beta {
initWith release
signingConfig signingConfigs.release-beta
}
}
}
The initWith
above just tells gradle that release-beta
should be a copy of the release
build type, only signed with a different key.
ReferenceURL : https://stackoverflow.com/questions/17040494/signing-product-flavors-with-gradle
'Development Tip' 카테고리의 다른 글
생성기 rspec : install을 찾을 수 없습니다. (0) | 2021.01.06 |
---|---|
Ruby on Rails 애플리케이션 이름을 변경하는 방법은 무엇입니까? (0) | 2021.01.06 |
배열의 요소 수 계산 (0) | 2021.01.06 |
.NET 테스트에서 모의 HttpClient를 전달하는 방법은 무엇입니까? (0) | 2021.01.06 |
MSbuild가 빌드 서버에 Visual Studio를 설치해야합니까? (0) | 2021.01.06 |