Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27574] Android: Replace SDK "build.properties" with gradle generated "BuildConfig" class

GitHub Issuen/a
TypeImprovement
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-04-10T21:54:49.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.1
ComponentsAndroid
Labelsandroid, build, gradle, properties, sdk
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-11-13T01:35:09.000+0000
Updated2020-04-10T21:54:49.000+0000

Description

*Summary:* When building the Titanium SDK, we generate a "build.properties" file (similar to an INI file) providing the Titanium library's version and build time information. This file is stored under APK "assets" and is read on app startup via the Java method below. [TiApplication.loadBuildProperties()](https://github.com/appcelerator/titanium_mobile/blob/5fbe78276e04049874e13bcc0a3874593f27254e/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java#L300) By default, gradle generates a BuildConfig Java class for all libraries and apps. We should use this feature instead of generating our own "build.properties" file. It will simplify our build process... and access to this info at runtime will be faster. https://developer.android.com/studio/build/gradle-tips#share-custom-fields-and-resource-values-with-your-app-code *Example:*
// The "build.gradle" file.
android {
	defaultConfig {
		buildConfigField('String', 'BUILD_VERSION', '"9.x.x"')
		buildConfigField('String', 'BUILD_TIMESTAMP', '"YYYY/MM/DD HH:MM"')
		buildConfigField('String', 'BUILD_GIT_HASH', '"HEAD"')
	}
}
*Note:* This information is logged on app startup as...
<AppName> <AppVersion> (Powered by Titanium <Version>.<GitHash>)
The above message gets logged in the code below... [ti.main.js#L15](https://github.com/appcelerator/titanium_mobile/blob/5fbe78276e04049874e13bcc0a3874593f27254e/common/Resources/ti.main.js#L15)

Comments

  1. Joshua Quick 2020-04-08

    After upgrading gradle via [TIMOB-27778], the current "master" and "9_0_X" branches are no longer picking up the generated "build.properties" file on the initial build. This means that Jenkins built SDKs for Android will return version "1.0.0". This can be seen in app builds, such as via Jenkin's mocha unit test output. This issue can be corrected with this ticket's proposed changes. This issue was caught before release.
  2. Joshua Quick 2020-04-08

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11605 PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11606
  3. Lokesh Choudhary 2020-04-08

    FR Passed. PR's Merged.
  4. Satyam Sekhri 2020-04-10

    Verified on: Mac OS: 10.15.4 SDK: 9.0.1.v20200409100807, 9.1.0.v20200409073825 Appc CLI: 8.0.0 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202003132109 Device: Pixel3(v10.0) emulator,

JSON Source