{"_id":"590a04f8ed80861900cbc7b8","user":"55b2d5626862a10d00887af9","__v":0,"category":{"_id":"590a04f3ed80861900cbc74c","__v":0,"version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-05T19:32:59.974Z","from_sync":false,"order":22,"slug":"troubleshooting","title":"Troubleshooting"},"parentDoc":null,"project":"55b2d5baa74a380d00e290c4","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-02-06T18:21:18.550Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":15,"body":"Here's an example of how you can display the build number for your app in a debug build.\nIn this example, we are using BuildConfig in the gradle file whose value is set to the standard buddybuild gradle property \"BUDDYBUILD_BUILD_NUMBER\". This will auto-generate BuildConfig identifiers that we reference in our source code via \"BuildConfig.BUILDNO\".\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\ndef bbBuildNumber = \\\"0\\\"; \\n\\tif (project.hasProperty('BUDDYBUILD_BUILD_NUMBER')) { \\n\\tbbBuildNumber = project.properties['BUDDYBUILD_BUILD_NUMBER']; \\n}\\n\\nandroid { \\n\\tdefaultConfig { \\n\\t\\tbuildConfigField \\\"String\\\", \\\"BUILDNO\\\", \\\"\\\\\\\"${bbBuildNumber}\\\\\\\"\\\" \\n\\t} \\n\\tbuildTypes { \\n\\t\\tdebug { \\n\\t\\t\\tbuildConfigField \\\"String\\\", \\\"BUILDNO\\\", \\\"\\\\\\\"${bbBuildNumber}\\\\\\\"\\\" \\n\\t}\\n}\",\n      \"language\": \"groovy\",\n      \"name\": \"build.gradle\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"TextView buildTitle = (TextView)findViewById(R.id.build_title); \\ntry { \\n\\tif (BuildConfig.BUILDNO.equals(\\\"0\\\")) { \\n\\t\\tbuildTitle.setText(getString(R.string.debug_build)); \\n\\t} else { \\n\\t\\tbuildTitle.setText(getString(R.string.build, BuildConfig.BUILDNO)); \\n\\t} \\n} catch(Exception e) { \\n\\te.printStackTrace(); \\n\\tbuildTitle.setText(getString(R.string.debug_build)); \\n}\",\n      \"language\": \"java\",\n      \"name\": \"Source Code\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"displaying-build-number-in-an-android-app-without-sdk-integration","type":"basic","title":"Displaying Build Number in an Android App without SDK Integration"}

Displaying Build Number in an Android App without SDK Integration


Here's an example of how you can display the build number for your app in a debug build. In this example, we are using BuildConfig in the gradle file whose value is set to the standard buddybuild gradle property "BUDDYBUILD_BUILD_NUMBER". This will auto-generate BuildConfig identifiers that we reference in our source code via "BuildConfig.BUILDNO". [block:code] { "codes": [ { "code": "\ndef bbBuildNumber = \"0\"; \n\tif (project.hasProperty('BUDDYBUILD_BUILD_NUMBER')) { \n\tbbBuildNumber = project.properties['BUDDYBUILD_BUILD_NUMBER']; \n}\n\nandroid { \n\tdefaultConfig { \n\t\tbuildConfigField \"String\", \"BUILDNO\", \"\\\"${bbBuildNumber}\\\"\" \n\t} \n\tbuildTypes { \n\t\tdebug { \n\t\t\tbuildConfigField \"String\", \"BUILDNO\", \"\\\"${bbBuildNumber}\\\"\" \n\t}\n}", "language": "groovy", "name": "build.gradle" } ] } [/block] [block:code] { "codes": [ { "code": "TextView buildTitle = (TextView)findViewById(R.id.build_title); \ntry { \n\tif (BuildConfig.BUILDNO.equals(\"0\")) { \n\t\tbuildTitle.setText(getString(R.string.debug_build)); \n\t} else { \n\t\tbuildTitle.setText(getString(R.string.build, BuildConfig.BUILDNO)); \n\t} \n} catch(Exception e) { \n\te.printStackTrace(); \n\tbuildTitle.setText(getString(R.string.debug_build)); \n}", "language": "java", "name": "Source Code" } ] } [/block]