Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27696] Android: Add "gradle.properties" support to app builds

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-01-31T11:00:24.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.0
ComponentsAndroid
Labelsandroid, build, gradle, properties, settings
ReporterHans Knöchel
AssigneeJoshua Quick
Created2019-12-22T10:23:33.000+0000
Updated2020-01-31T11:00:24.000+0000

Description

*Summary:* Titanium app developers would like the ability to set up their own "gradle.properties" file according to Google's documentation. We should add support for this and allow this file to override the properties defined by Titanium's build system. https://developer.android.com/studio/build#properties-files *Recommended Solution:* Copy the properties from the following project file...
./platform/android/gradle.properties
These properties should be copied to the end of the Titanium generated "gradle.properties" file so that the app dev's properties can override the ones we set.

Comments

  1. Joshua Quick 2020-01-07

    I don't think this is necessary. The properties you set in the gradle.properties file are copied to the gradle project.properties dictionary in groovy. Which means you can set these properties in your build.gradle script instead. The below is an example on how to add properties via a Titanium project's ./platform/android/build.gradle file.
       project.ext['android.useAndroidX'] = 'true'
       project.ext['android.enableJetifier'] = 'true'
       project.ext['api.key'] = 'MyKey'
       
    Note that I think android.useAndroidX should be hardcoded to true once Titanium switches over to AndroidX. The local.properties file is only for setting paths to the Android SDK, Android NDK, and CMake. The options are limited. What are you after in this file? (Or perhaps you know something I don't?)
  2. Hans Knöchel 2020-01-07

    I was checking for parity with our native Android gradle project, but I think you're right and this can be done via the above as well. I will close the PR and you can resolve this ticket! *EDIT*: Agree with the local.properties, but the gradle.properties should really be able to be overwritten, since store a few other things there as well, which the above syntax looks a bit odd to. And there shouldn't be any downside of making this fully configurable.
  3. Joshua Quick 2020-01-07

    Yeah, I can see setting properties via "gradle.properties" being more natural. Especially when Google's official docs tell you to do so. I'll try to be open minding about this. FYI: Setting properties via project.ext is commonly done as well. For example... https://github.com/google/ExoPlayer/blob/release-v2/constants.gradle https://github.com/facebook/facebook-android-sdk/blob/master/constants.gradle
  4. Joshua Quick 2020-01-11

    PR (main): https://github.com/appcelerator/titanium_mobile/pull/11428
  5. Samir Mohammed 2020-01-31

    Closing ticket, fix verified in SDK version 9.0.0.v20200130113429 Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11428

JSON Source