Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Auto Build ID

In the release note, a new tag for the blackberry-tablet.xml files discusses:

 

You can now use the buildId flag to create automatically incrementing version numbers for your application.

 In my XML file, I did:

<buildId>100</buildId>

 

After a clean rempile and deployment to 1.0.1 simulator, the output shows:

 

actual_version: 1.1.5.100

 

If I do another clean recompile and re-deployment to the simulator, the actual_version does not change.

 

Does anyone know how to turn on the "automatically incrementing version numbers"?

 

My app-amxl file has versionNumber set to 1.1.5

 

 

Please use plain text.
Developer
alinium
Posts: 31
Registered: ‎12-25-2010
My Device: PlayBook
My Carrier: Rogers

Re: Auto Build ID

Check out this post:

http://docs.blackberry.com/en/developers/deliverables/23959/Signing_your_application_1422721_11.jsp#...

"You can change the build number by updating the buildId element in your blackberry-tablet.xml file. Alternatively, you can specify the build ID using the buildId command line option when you package your application using theblackberry-airpackager tool."

 

So it looks like you can do it from the command line. But I don't think the IDEs have support to do it automatically yet. But if someone knows a way to do it from the IDE, please let me know! I'm not planning on ditching compiling from the IDE just for this one command-line feature.

_________________
My apps: PlayText
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Auto Build ID

Will at least this will get around the issue of having to change the full version number to re-sign a trial version of the application.
Please use plain text.
Developer
gluth
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Auto Build ID

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
     2010-03-30 21:45:55

     incrementVersionNumber
     Increments version number in the file set as parameter in format set as parameter

     root
     ====================================================================== -->
<project name="incrementVersionNumber" default="replaceVersionNumber">
    <description>
            Increments version number in the file set as parameter in format set as parameter
    </description>

    <!-- - - - - - - - - - - - - - - - - -
          target: readVersion
         - - - - - - - - - - - - - - - - - -->
    <target name="readVersion">
        <buildnumber file=".buildNumber"/>
    </target>

    <!-- =================================
          target: replaceVersionNumber
         ================================= -->
    <target name="replaceVersionNumber" depends="readVersion" description="Increments version number in the file set as parameter in format set as parameter">
        <echo>Version: ${build.number}</echo>
        <replaceregexp
                file="BlackBerry_App_Descriptor.xml"
                match=" Version=&quot;(.*)\.[^ ]+&quot;"
                replace=" Version=&quot;\1.${build.number}&quot;"
                byline="true"/>
    </target>

    <!-- =================================
          target: replacePlayBookVersionNumber
         ================================= -->
    <target name="replacePlayBookVersionNumber" depends="readVersion" description="Increments version number in the file set as parameter in format set as parameter">
        <echo>Version: ${build.number}</echo>
        <replaceregexp
                match="&lt;versionNumber&gt;([^&lt;]+)\.[0-9]+&lt;/versionNumber&gt;"
                replace="&lt;versionNumber&gt;\1.${build.number}&lt;/versionNumber&gt;"
                byline="true">
                <fileset dir="." casesensitive="yes">
                    <include name="**/*-app.xml"/>
                </fileset>
        </replaceregexp>
    </target>
</project>

 

This is my autoversion build file executed from Ant within FlashBuilder or Eclipse. It supports standard BlackBerry phone projects and PlayBook. Distributed at WTFPL license.

 

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Please use plain text.
Developer
alinium
Posts: 31
Registered: ‎12-25-2010
My Device: PlayBook
My Carrier: Rogers

Re: Auto Build ID

[ Edited ]

I edited gluth's script to make it work in FlashBuilder. Below are the steps you can do to make it work too.

Note: don't add the build number to the *-app.xml file like gluth's script suggests doing - you won't be able to run the app if you do that. *-app.xml version number should be 3 numbers only (x.x.x) and not 4 (x.x.x.x)

 

  • First add Java Development Tools in Flash Builder for Ant support. See instructions here
  • Restart FlashBuilder
  • Use the updated ANT file that I've attached below. I've updated some of the regular expressions. Save the file as 'build.xml'.
  • Right-click on build.xml, Run As->Ant Build...
    • Targets>'incrementBuildNumber'
    • Apply
  • You can run the Ant script by clicking on the Run External Tools icon in the main toolbar. You will have to do this every  time you want to update the build number. So you could just run the Ant file every time before you click the Run/Debug button. Alternatively...
  • ... you can have it setup to run every time your project is run. To do this, right click on your Project->Properties->Builders->Import...
    • Select the ANT configuration you just created.
    • Order it after 'Flex' but before 'AIR application.xml Builder'. I'm not sure about the ordering, but my logic goes like this: 'Flex' needs to run first to compile all the actionscript source files and detect any compile time errors. 'AIR application.xml builder' is probably referring to the *-app.xml and should run after my ANT script has updated version numbers. Note that in the final *-app.xml that gets packaged into the BAR file, the contents of the blackberry-tablet.xml are appended to the end of it. So although you're not suposed to directly add the build number to the *-app.xml, it gets added there indirectly through the blackberry-tablet.xml file.
My build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
     2010-03-30 21:45:55

     incrementVersionNumber
     Increments version number in the file set as parameter in format set as parameter

     root
     ====================================================================== -->
<project name="incrementVersionNumber" default="incrementBuildNumber">
    <description>
            Increments version number in the file set as parameter in format set as parameter
    </description>

    <!-- - - - - - - - - - - - - - - - - -
          target: readVersion
         - - - - - - - - - - - - - - - - - -->
    <target name="readVersion">
        <buildnumber file=".buildNumber"/>
    </target>

    <!-- =================================
          target: replaceVersionNumber
         ================================= -->
    <target name="replaceVersionNumber" description="Increments buildID number in blackberry-tablet.xml">
        <echo>Version: ${build.number}</echo>
        <replaceregexp
                file="src/blackberry-tablet.xml"
                match="&lt;buildId&gt;(\D*)(\d+)(\D*)&lt;/buildId&gt;"
                replace="&lt;buildId&gt;\1${build.number}\3&lt;/buildId&gt;"
                byline="true"/>
    </target>

	<!-- =================================
          target: replaceSourceVersionNumber
          You can optionally use this target to update the version number in any other files, perhaps some file in your source code
         ================================= -->
    <target name="replaceSourceVersionNumber" description="Increments version number by incrementing build number in Main.as">
        <echo>Version: ${build.number}</echo>
        <replaceregexp
        		file="src/Main.as"
                match  ="public static const VERSION:String = &quot;(.+)\.[0-9]+&quot;;"
                replace="public static const VERSION:String = &quot;\1.${build.number}&quot;;"
                byline="true" />
    </target>
	
	
	<!-- =================================
          target: incrementBuildNumber
         ================================= -->
	<target name="incrementBuildNumber" depends="readVersion" description="Increment build number across all related files">
		<echo>Version: ${build.number}</echo>
		<antcall target="replaceVersionNumber"/>
		<antcall target="replaceSourceVersionNumber"/>
	</target>
	
</project>

 Also make sure that your blackberry-tablet.xml has the buildId tag in it

 

blackberry-tablet.xml:

<buildId>0</buildId>

 

Hope this helps others!

 

_________________
My apps: PlayText
Please use plain text.
New Contributor
alouw
Posts: 4
Registered: ‎06-26-2011
My Device: Playbook & Torch
My Carrier: Vodafone

Re: Auto Build ID

The option they probably added is in the blackberry-airpackager tool.

 

You can use that with -buildId filename.txt to read filename.txt and increment the number in it and put that as build number in the compiled file.

 

I simply use a file called build.nr and edit it with just a '1' in it. After using airpackager it auto-increments.. (which is pretty neat).

 

Regards,

Albert

 

Please use plain text.
New Developer
ufoloko
Posts: 27
Registered: ‎09-19-2008
My Device: 8900

Re: Auto Build ID

Maybe you can explain how to set ant script for application ?

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800
My Carrier: beginner developer

Re: Auto Build ID

Hi,

Where you put this file build.xml to increment the number of build?

Please use plain text.
Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Auto Build ID

[ Edited ]

Just to bump this up, the solution from FlashBuilder is really easy:

 

* Under Build Packaging < BlackBerry > Advanced, add: "-buildId build.txt"

* create build.txt in your /src folder, and populate it with a "1"

 

Your builds now autoincrement :smileyhappy:


EDIT - Well it seems a little hit or miss...sometimes it increments, sometimes it doesn't.

Please use plain text.
Trusted Contributor
foufou
Posts: 109
Registered: ‎11-15-2011
My Device: blackberry 9800
My Carrier: beginner developer

Re: Auto Build ID

Where I can find "Advanced" to add  "-buildId build.txt"???

Please use plain text.