Вопрос

I found this link https://stackoverflow.com/questions/6579697/android-how-to-make-the-versioncode-update-automatically-with-every-build that contains the following code:

#!/usr/bin/env bash                                                             

MANIFEST="AndroidManifest.xml"                                                  

if [ -f $MANIFEST ]                                                             
then                                                                            
    LINE=$(grep -o ${MANIFEST} -e 'android:versionCode="[0-9]*"');              
    declare -a LINE;                                                            
    LINE=(`echo $LINE | tr "\"" " "`);                                          
    VERSION=(${LINE[1]});                                                       
    INCREMENTED=$(($VERSION+1))                                                 
    sed "s/android:versionCode=\"[0-9]*\"/android:versionCode=\"${INCREMENTED}\"/" $MANIFEST > $MANIFEST.tmp && mv $MANIFEST.tmp $MANIFEST
    git add $MANIFEST                                                           
    echo "Updated android:versionCode to ${INCREMENTED} in ${MANIFEST}";        
fi   

I'm using a TortoiseSVN with a windows SVN server however (VisualSVN) so I'm wondering if this could be put into a cygwin command somehow so that the pre-commit hooks in svn can run this? I've not used cygwin much, but am looking for a way to have my version name update every time a commit is built.

Edit: actually it looks like you can use a tool call FARThttp://fart-it.sourceforge.net/ to find and replace text, so i may be able to write a batch script in the SVN pre-commit to find and replace the text.

Edit #2: FART would be more complicated, I'm going to try using the first script, but replace "git add" with "svn add" and see if that works

Это было полезно?

Решение

You can use Maven (which supports Android development) with buildnumber plugin.

It let's you create build numbers via an SCM, via a sequential build number, or via a timestamp. See usage page.

Другие советы

In the same post you mentioned, I posted a different solution, because SVN boldly recommends not changing the commit content with a pre-commit hook , you can make it all go corrupt! Your manifest can keep the same versionCode forever in svn, instead you should change /bin/AndroidManifest.xml , that is the one which will be packaged in the .apk file

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top