{"_id":"590a04f6ed80861900cbc793","user":"55b2d5626862a10d00887af9","category":{"_id":"590a04f3ed80861900cbc73c","__v":0,"version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-11T21:56:19.274Z","from_sync":false,"order":4,"slug":"android-quickstart","title":"Android Quickstart"},"project":"55b2d5baa74a380d00e290c4","__v":0,"version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-08-29T20:18:16.975Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"VersionCode\"\n}\n[/block]\nBuddybuild can update the VersionCode automatically for you. The process is done on the fly, does not require write access to the repo, and no changes will be committed back to the repo.\n\nAll you need to do is to turn on \"Auto-Versioning\" in the settings.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5fe9b56-Settings_-_Auto_versioning_-_Android.png\",\n        \"Settings - Auto versioning - Android.png\",\n        1500,\n        582,\n        \"#cfd3d6\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"VersionName\"\n}\n[/block]\nThe best practice is to update VersionName in the build.gradle, and Buddybuild will simply respect that. Here is a quick example to change the VersionName to git tag:\n\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"/*\\n * Gets the version name from the latest Git tag\\n */\\ndef getVersionName = { ->\\n    def stdout = new ByteArrayOutputStream()\\n    exec {\\n        commandLine 'git', 'describe', '--tags'\\n        standardOutput = stdout\\n    }\\n    return stdout.toString().trim()\\n}\\n\\n...\\n  \\n  \\nandroid {\\n    ...\\n    buildTypes {\\n        debug {\\n            versionName getVersionName()\\n        }\\n    }\\n    ...\\n}\\n\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nYou also have access to the enviroment variables listed here: [Custom Build Steps](doc:custom-prebuild-and-postbuild-steps)","excerpt":"","slug":"android-auto-versioning","type":"basic","title":"Auto Versioning"}
[block:api-header] { "type": "basic", "title": "VersionCode" } [/block] Buddybuild can update the VersionCode automatically for you. The process is done on the fly, does not require write access to the repo, and no changes will be committed back to the repo. All you need to do is to turn on "Auto-Versioning" in the settings. [block:image] { "images": [ { "image": [ "https://files.readme.io/5fe9b56-Settings_-_Auto_versioning_-_Android.png", "Settings - Auto versioning - Android.png", 1500, 582, "#cfd3d6" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "VersionName" } [/block] The best practice is to update VersionName in the build.gradle, and Buddybuild will simply respect that. Here is a quick example to change the VersionName to git tag: [block:code] { "codes": [ { "code": "/*\n * Gets the version name from the latest Git tag\n */\ndef getVersionName = { ->\n def stdout = new ByteArrayOutputStream()\n exec {\n commandLine 'git', 'describe', '--tags'\n standardOutput = stdout\n }\n return stdout.toString().trim()\n}\n\n...\n \n \nandroid {\n ...\n buildTypes {\n debug {\n versionName getVersionName()\n }\n }\n ...\n}\n", "language": "groovy" } ] } [/block] You also have access to the enviroment variables listed here: [Custom Build Steps](doc:custom-prebuild-and-postbuild-steps)