2
でversionNameSuffixを取得する方法を私はのAndroid Studioは、私のGradleファイルでコード
defaultConfig {
minSdkVersion 17
targetSdkVersion 25
versionCode 2
versionName "1.0"
versionNameSuffix ".alpha1"
setProperty("archivesBaseName", "MyApp.$versionName.$versionCode$versionNameSuffix")
signingConfig signingConfigs.config
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
ようVersionNameとVersionCodeを宣言し、私のアプリケーションで私がversionCodeとversionNameは
applicationInformation.VERSIONNAME = BuildConfig.VERSION_NAME;
applicationInformation.VERSIONCODE = BuildConfig.VERSION_CODE;
しかし、どのように盗んことができますversionNameSuffixを入手できますか? BuildConfigにはフィールドがありません。あなただけversionNameSuffix
が必要な場合は、このようなあなたのbuild.gradle
に新しいBuildConfig変数を作成することができます
public static final String VERSION_NAME = "0.71.alpha1";
:
buildTypes {
debug {
buildConfigField "String", "VERSION_NAME_SUFFIX", "\"" + defaultConfig.versionNameSuffix + "\""
}
release {
buildConfigField "String", "VERSION_NAME_SUFFIX", "\"" + defaultConfig.versionNameSuffix + "\""
}
}
することができます
は完璧に動作します、ありがとう! –