Building Apache Flex 4.8 on Windows
On July 24th the Apache Flex project announced the first release of a Flex SDK. This was an important step in the handing over of the Flex SDK from Adobe to the Apache project led by the community. Apache Flex 4.8 essentially contains the same code as the 4.6 Flex SDK, the last version that was released by Adobe.
Although I wouldn't use Flex for a project that runs in the browser, I still believe that it is a great framework for developing desktop applications that run using the Adobe AIR runtime. This is what promoted me to get my hands dirty with Apache Flex 4.8 and try and get the traditional Hello World application running. This blog post is going to run through how I got up and running with Apache Flex 4.8.
Everything that is needed have been well documented in the README file inside the root folder of the Apache Flex 4.8 binary download.
- Apache Flex 4.8 binaries is the obvious one. Make sure you click to download the Windows binaries from the "Download Apache Flex™ 4.8.0 (binaries)" section on the Apache Flex download page.
- Ant is required to run a build script that gathers all the third party dependencies required by the Flex SDK. This can be no earlier than version 1.7.0. Here are some instructions on how to install Ant. This can be downloaded from the official Apache Ant website.
- JDK (Java Development Kit) that is used by the Ant build scripts. It is very important that you don't get the latest JDK7 version as I found that the build script would fail to build the project. I was able to build successfully with the JDK6 version that can be downloaded here (click the download button in the JDK column for the "Java SE 6 Update 33" section).
- Adobe AIR SDK used to create desktop applications in parallel with the Flex framework. I would just go with downloading the latest version of AIR, which is version 3.3.
- IDE to develop Flex & AIR applications. My IDE of choice is the Adobe Flash Builder plugin (version 4.0) for Eclipse (Indigo version).
Getting the third party dependencies
Once I had downloaded the Windows binaries for Apache Flex 4.8 I was already ready to go as I already use Ant frequently and had the JDK6 installed. I extract the contents of the downloaded zip (apache-flex-sdk-4.8.0-incubating-bin.zip) and placed the contents inside a directory named 4.8.0 inside the directory that contains previous Flex sdks used in eclipse. So, I extracted the downloaded zip into an empty 4.8.0 directory in the C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks</em> directory.
The image below shows all the commands I entered into Windows PowerShell.
Now that all the dependencies for the Apache Flex 4.8 framework have been gathered I was under the impression the 4.8.0 SDK was ready. I created a new Flex project and made sure I added the new 4.8.0 SDK to the workspace SDKs (click "Configure Flex SDKs..." on the create new Flex project dialog). Unfortunately I was presented with an error in the Problems tab as shown below.
This occurs because I haven't set the environment variable that points to the directory that holds the playerglobal.swc. Firstly I downloaded the playerglobal.swc (version 11.1 at the time of writing). I placed the downloaded file into the frameworks\libs\player\11.1 directory (creating the player & 11.1 directories as they didn't exist). Next I located (root folder of the SDK) and renamed the env-template.properties file to env.properties. Next I opened the newly renamed file and located the line (line 72) that is equal to "#env.PLAYERGLOBAL_HOME=". I updated this line to equal "env.PLAYERGLOBAL_HOME=libs\player\" ensuring that I removed the hash at the beginning of the line so it is no longer recognised as a comment. Once this is done, rebuilding the project makes the problem disappear and the application is now able to run.
Getting it to work with AIR
When trying to create a new Flex project that runs using AIR I found that I couldn't ever get past the final window to create the project. In order to get passed this I simply copied a version of the AIR SDK into the 4.8.0 directory. Trying to create a new project was now successful however an error displayed below is shown.
This error is similar to the playerglobal error that was solved previously. Simply opening the "env.properties" and locating the line (51) "#env.AIR_HOME=". Changing this line to "env.AIR_HOME=..\" and then rebuilding the project causes the error to disappear and the application is able to run.
Here is quick list of the tasks I done.
- Download Apache Flex 4.8 binaries add place in SDKs directory.
- Run thirdparty-downloads target in the build script located in the frameworks directory (ant thirdparty-downloads).
- Rename "env-template.properties" to "env.properties".
- Copy playerglobal.swc into the frameworks/libs directory ensuring the directory it is contained in is named "11.1".
- Update the env.PLAYERGLOBAL_HOME inside the "env.properties" file to a relative path from the frameworks directory to the directory that contains playerglobal.swc.
- Copy AIR SDK into the 4.8.0 SDK directory.
- Update the env.AIR_HOME to "../" which will point the SDK to the airglobal.swc file.
If this is too much, which seems to be the general consensus for some then there is an AIR application that will install the SDK for you, but I haven't used it so not sure how effective it is.
If you have had any problems with the instructions I've attempt to explain then feel free to send me a tweet.
Just a little side note, when adding the SDK to your IDE (especially for eclipse), you may find that you don't have any of the flash packages (flash.events for example). If this is the case, it can be a right head scratcher, to solve it remove playerglobal.swc from the library path (Project > Properties > Flex Build Path > Library Path). Once this is done, re-add the playerglobal.swc, choosing the one that is located in the Apache Flex 4.8 SDK folder that you have just built (SDKs directory > 4.8.0 > frameworks > libs > player > 11.1 > playerglobal.swc). Then clean your project and hopefully any unresolved packages should not be resolved.