Question
Is it possible to either add things to the default props of the index.android.js
from the build.gradle or any file at runtime?
OR
Grab the versionCode
from the build.gradle
file from within my react-native code?
Problem
I'm trying to programmatically have a version number in my application based on the version, build and git sha. The format is essentially version-gitsha-jenkinsBuildNumber
(for example 1.0.0-abc1234-83
). I was able to get this to work on iOS by using a bash script to add it to the Info.plist and then followed How to read Info.Plist at run-time in react-native iOS app? in order to add them to my default props in my index.ios.js
. I cannot find a way to do this in the build.gradle
.
What I've Tried
Right now, I'm replacing the versionName
string in the defaultConfig with the git sha using something similar to what I found here: How to update version number of react native app
Then grabbing it inside react native with react-native-device-info
. I'm also pulling the version number 1.0.0
from the package.json. Lastly I wanted to add the jenkins build number to the versionCode
of the defaultConfig
but I have no way of getting it out with react-native-device-info
.
Any help would be much appreciated!