首页  编辑  

安卓中自动增加编译版本号

Tags: /Android/   Date Created:
Auto increment build number in Android Studio
Android Studio中自动增加编译版本号

修改 app build.gradle,在前面修改为类似:
def vcode = new Date().format('yyyyMMdd').toInteger()
def buildNumber = 0;
def vb = new File("version.build")
if (vb.exists())
buildNumber = vb.readLines()[0].toInteger()
vb.write((++buildNumber).toString());

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.comapny.app"
minSdkVersion 15
targetSdkVersion 27
versionCode vcode
versionName "2.0" + buildNumber.toString()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}