How to write build time stamp into apk

后端 未结 10 640
别跟我提以往
别跟我提以往 2020-12-02 07:57
  1. Making some changes in Android Contacts package
  2. Using mm (make) command to build this application

Because I have to change and

10条回答
  •  醉话见心
    2020-12-02 07:59

    For time stamping and versioning, build.gradle/android/defaultConfig:

    def buildDateStamp = new Date().format("yyyyMMdd").toInteger()
    versionCode buildDateStamp
    versionName "$buildDateStamp"
    buildConfigField "String", "BUILD_DATE_STAMP", "\"$buildDateStamp\""
    

    Usage in code: BuildConfig.BUILD_DATE_STAMP

    resValue "string", "build_date_stamp", "$buildDateStamp"
    

    Usage in xml: "@string/build_date_stamp"

    Caveat: adding HHmm will cause errors (probably integer overflow)

提交回复
热议问题