Android builds from Hudson are challenging in a completely different way than the iPhone builds. The challenges are mainly centered around updating the Android manifest file (which is owned by the Android development team, not the team doing the builds). So we need to dynamically load and change this file from version control before we build.
1. The svn control and tagging from Hudson is handled in the same way as the iPhone builds (see Hudson iPhone builds pt. 1)
2. Since we need to update the Android manifest file for each build, we need a build.xml that is different than a development build.xml and can handle the manifest update steps. The way we're handling this now is by taking the developer build.xml (which was originally created by the build team) and adding or ANT replace targets to it. We then overwrite the existing build.xml with this one every time.
There's a possible issue here in that the developers could alter the build.xml, and we'd need to handle it dynamically also (do the same thing that we're doing for the manifest). In that case it should be possible to create an ANT build.xml to alter the Android build.xml every run. But for now our first step is to just copy over the altered build.xml and overwrite the dev one:
xcopy /y/q "D:\Property_files\Android_trunk\build.bak4" D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\build.xml
3. The local.properties file is critical for these builds and will also vary according to build machine. So next step is to copy that file over:
xcopy /y/q "D:\Property_files\Android_trunk\local.properties" D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk
4. For Android builds it's critical that the version.code be incremented each build. The new build must have a higher value for version.code in the Android manifest, or loading the app should fail for the user. So the next step in the build is to copy over a build.number file that will then get incremented by an ANT task. This file follows standard ANT increment format (will go in detail in another post):
xcopy /y/q "D:\Property_files\Android_trunk\build.number" D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk
5. We always do an ant clean task before build:
setlocal
set JAVA_HOME=D:\ProgramFiles\Java\jdk1.6.0_11
set ANDROID_HOME=D:\ProgramFiles\Java\android-sdk-windows
set ANT_HOME=D:\ProgramFiles\Ant\apache-ant-1.7.1\apache-ant-1.7.1
cd D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk
ant clean
6. We then originally ran a gamut of replace tasks on the manifest file. Dev have revised the procedure so that the only extra task we need to do is update that version.code value:
setlocal
set JAVA_HOME=D:\ProgramFiles\Java\jdk1.6.0_11
set ANDROID_HOME=D:\ProgramFiles\Java\android-sdk-windows
set ANT_HOME=D:\ProgramFiles\Ant\apache-ant-1.7.1\apache-ant-1.7.1
cd D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk
ant updateversioncode
7. Then run release to create the Android build:
setlocal
set JAVA_HOME=D:\ProgramFiles\Java\jdk1.6.0_11
set JAVA_OPTS=-Xms64m -Xmx256m
set ANDROID_HOME=D:\ProgramFiles\Java\android-sdk-windows
set ANT_HOME=D:\ProgramFiles\Ant\apache-ant-1.7.1\apache-ant-1.7.1
set ANT_OPTS=-Xms64m -Xmx256m
cd D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk
ant release
8. We then sign the release. Since the build machines are 'locked down' we pass these values in through the build itself:
setlocal
set JAVA_HOME=D:\ProgramFiles\Java\jdk1.6.0_11
set ANDROID_HOME=D:\ProgramFiles\Java\android-sdk-windows
set ANT_HOME=D:\ProgramFiles\Ant\apache-ant-1.7.1\apache-ant-1.7.1
cd D:\ProgramFiles\Java\jdk1.6.0_11\jre\bin
jarsigner -keystore D:\ProgramFiles\Java\jdk1.6.0_11\bin\blah.keystore -storepass blah2 -keypass blah2 -signedjar D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\bin\blah3pre.apk D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\bin\blah3-unsigned.apk blah_key
9. We then need to do a zipalign on the output, this is required for Android deliveries:
setlocal
set JAVA_HOME=D:\ProgramFiles\Java\jdk1.6.0_11
set ANDROID_HOME=D:\ProgramFiles\Java\android-sdk-windows
set ANT_HOME=D:\ProgramFiles\Ant\apache-ant-1.7.1\apache-ant-1.7.1
cd D:\ProgramFiles\Java\android-sdk-windows\tools
zipalign -f -v 4 D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\bin\blahpre.apk D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\bin\blah.apk
10. Since we incremented the build.number file we need to move it back so that the next build increments again:
xcopy /y/q "D:\Hudsonb\jobs\Android-trunk\workspace\android_trunk\build.number" D:\Property_files\Android_trunk
Next post, diving into the details of the manifest replace steps and how Android uses the properties files
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment