User Tools

Site Tools


android:android_build_configuration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
android:android_build_configuration [2019/08/15 20:44]
timm created
android:android_build_configuration [2019/08/19 18:35] (current)
timm
Line 6: Line 6:
  
 To begin with the process takes advantage of Gradle environment variables. ​ Four variables are used, versionMajor,​ versionMinor,​ versionHotfix and buildNum. ​ The first three are currently manually set and represent the application version number. ​ 2.4.1 for example. ​ The buildNum variable is retrieved from a Jenkins environment variable or hardcoded to 9999 for desktop builds. ​ The Jenkins build number is always unique for the build being created. ​ The following code block is inserted in the build.gradle file for the Application being built. To begin with the process takes advantage of Gradle environment variables. ​ Four variables are used, versionMajor,​ versionMinor,​ versionHotfix and buildNum. ​ The first three are currently manually set and represent the application version number. ​ 2.4.1 for example. ​ The buildNum variable is retrieved from a Jenkins environment variable or hardcoded to 9999 for desktop builds. ​ The Jenkins build number is always unique for the build being created. ​ The following code block is inserted in the build.gradle file for the Application being built.
 +<code java>
 // Major.Minor.Hotfix is defined here to identify the build correctly // Major.Minor.Hotfix is defined here to identify the build correctly
 // These are used in the Manifest to correctly set the versionCode and versionName // These are used in the Manifest to correctly set the versionCode and versionName
Line 17: Line 17:
     buildNum ​     = System.getenv("​BUILD_NUMBER"​) as Integer ?: 9999     buildNum ​     = System.getenv("​BUILD_NUMBER"​) as Integer ?: 9999
 } }
 +</​code>​
 +To use this the following code is added to the defaultConfig section of the same build.gradle script.
 +<code java>
 +// Compute the versionCode and versionName which is used in the Manifest to identify the build
 +versionCode = versionMajor * 1000000 + versionMinor * 10000 + buildNum
 +versionName = String.valueOf(versionMajor) + "​."​ + String.valueOf(versionMinor) + "​."​ + String.valueOf(versionHotfix)
 +</​code>​
 +        ​
 +The code above creates two Gradle environment variables "​versionCode"​ and "​versionName"​. ​ The versionCode variable is used to create a build number which is substituted into the AndroidManifest.xml for each build. ​ This is the number that must role forward for every APK created. ​ It take the major, minor and build number to create a unique build number. ​ The key is the use of the Jenkins build number which is always moving forward for any given release build. ​ The versionName is just the normal human readable version name such as 2.4.1. ​ It is also used in the AndroidManifest.xml file and is grabbed by the About page in each app.  ​
  
-To use  
android/android_build_configuration.1565901894.txt.gz · Last modified: 2019/08/15 20:44 by timm