Qaiser Butt Qaiser Butt - 3 months ago 28
Android Question

updating android app version and build number using script without changing androidManifest VersionCode and VersionName

I have been able to automatic change my versionCode to be used as build number in androidmanifest.xml to my current git commit number through a script file before game start. But due to a particular reason, i dont want to use versionCode to be used as my game build number. I want to use something other than versionCode and VersionName where i can save my git commit number through script before game start and later during game i can read that value and show in my game. So i need two things


  1. how to create an extra Tag in androidManifest file where i can save this value

  2. And script to change that Tag value to be used in the script file before game run



i use the following script to change versionCode tag in manifest

newverfull=$(git --git-dir="../../.git" --work-tree="../../" rev-list master | wc -l)

manf=AndroidManifest.xml

newvers=`echo $newverfull | sed 's/[^0-9].*$//'`

vers=`sed -n '/versionCode=/s/.*"\([0-9][0-9]*\)".*/\1/p' $manf`

sed /versionCode=/s/'"'$vers'"'/'"'$newvers'"'/ $manf >new$manf && cp new$manf $manf && rm -f new$manf


I appreciate your help. Thanks!

Answer

i managed to change my script posted earlier. I also make a meta data in the manifest file and change its value through the below script. Thanks for the help Cheers! here is the change

newverfull=$(git --git-dir="../../.git" --work-tree="../../" rev-list master | wc -l)

manf=AndroidManifest.xml

verbase=echo $newverfull | sed 's/\(.*\.\)\([0-9][0-9]*\).*$/\1/'

vername=sed -n '/GameVersion/s/.*"\([^"]*\)".*/\1/p' $manf

sed /GameVersion/s/'"'$vername'"'/'"'$verbase'"'/ $manf >new$manf && cp new$manf $manf && rm -f new$manf

Comments